- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1719 Articles for Big Data Analytics
525 Views
If you want to delete all documents from the collection, you can use deleteMany(). Let us first create a collection and insert some documents to it:> db.deleteDocumentsDemo.insert({"Name":"Larry", "Age":23}); WriteResult({ "nInserted" : 1 }) > db.deleteDocumentsDemo.insert({"Name":"Mike", "Age":21}); WriteResult({ "nInserted" : 1 }) > db.deleteDocumentsDemo.insert({"Name":"Sam", "Age":24}); WriteResult({ "nInserted" : 1 })Now display all the documents from the collection. The query is as follows:> db.deleteDocumentsDemo.find().pretty();The following is the output:{ "_id" : ObjectId("5c6ab0e064f3d70fcc914805"), "Name" : "Larry", "Age" : 23 } { "_id" : ObjectId("5c6ab0ef64f3d70fcc914806"), "Name" : "Mike", "Age" : 21 } { "_id" : ObjectId("5c6ab0f864f3d70fcc914807"), "Name" ... Read More
224 Views
To delete document from a collection in MongoDB, you can use the deleteOne() method. Let us first create a collection and insert some documents to it:> db.deleteDocumentsDemo.insert({"Name":"Larry", "Age":23}); WriteResult({ "nInserted" : 1 }) > db.deleteDocumentsDemo.insert({"Name":"Mike", "Age":21}); WriteResult({ "nInserted" : 1 }) > db.deleteDocumentsDemo.insert({"Name":"Sam", "Age":24}); WriteResult({ "nInserted" : 1 })Now display all the documents from the collection. The query is as follows:> db.deleteDocumentsDemo.find().pretty();The following is the output:{ "_id" : ObjectId("5c6ab0e064f3d70fcc914805"), "Name" : "Larry", "Age" : 23 } { "_id" : ObjectId("5c6ab0ef64f3d70fcc914806"), "Name" : "Mike", "Age" : 21 } { "_id" : ObjectId("5c6ab0f864f3d70fcc914807"), "Name" : "Sam", ... Read More
322 Views
To delete the documents from a collection in MongoDB, you need to use remove() method. The syntax is as follows:db.yourCollectionName.remove(yourDeleteValue);Here, let us create a collection with some documents. The query is as follows:>db.deleteDocuments.insert({"UserId":1, "UserName":"Bob", "UserTechnicalSubject":"Introducti on to PL/SQL"}); WriteResult({ "nInserted" : 1 }) >db.deleteDocuments.insert({"UserId":2, "UserName":"Carol", "UserTechnicalSubject":"Introduction to MongoDB"}); WriteResult({ "nInserted" : 1 }) >db.deleteDocuments.insert({"UserId":3, "UserName":"John", "UserTechnicalSubject":"Introduction to MySQL"}); WriteResult({ "nInserted" : 1 }) >db.deleteDocuments.insert({"UserId":4, "UserName":"Maxwell", "UserTechnicalSubject":"Introduction to SQL Server"}); WriteResult({ "nInserted" : 1 })You can display all documents from the collection we created above with the help of find() command. The query is as follows:> db.deleteDocuments.find().pretty();The following ... Read More
220 Views
To insert new documents into a MongoDB collection, you need to use insert() method or save() method.Case 1: Using insert() method.The syntax is as follows:db.yourCollectionName.insert(yourDocument);Case 2: Using save() method.The syntax is as follows:db.yourCollectionName.save(yourDocument);In the above syntax, if your collection name does not exist then MongoDB will create a new collection and insert the document in the collection.The query to insert new documents is as follows for both the cases discussed above.Case 1: Using insert() method. The query is as follows:> db.userInformation.insert({ ... "Name":"John", ... Age:30, ... isStudent:false, ... "Subjects":["Introduction to java", "Introduction to MongoDB"] ... ... Read More
114 Views
To drop a collection in MongoDB, you need to use drop() command. The syntax is as follows:db.yourCollectionName.drop();The above syntax returns true or false. It returns true if the collection is dropped successfully otherwise false.Let us first display all collection names from MongoDB. Here, we have a database ‘sample’ that contains some collections. First you need to switch to the ‘sample’ database. The query is as follows:> use sample; switched to db sampleNow display all collection names with the help of show command. The query is as follows:> show collections;The following is the output:bookInformation userInformationAbove, you can see we have the ... Read More
260 Views
To create a new collection in MongoDB, you need to use createCollection() method.Case 1: The easiest syntax to create a new collection in MongoDB is as follows:db.createCollection(“yourNewCollectionName”);Case 2: The alternative syntax to create a new collection in MongoDB is as follows:db.createCollections(“yourNewCollectionName”, options);The options parameter above can have the following values:capped field which returns boolean type which will either true or false.autoIndexId field which returns boolean type which will either true or false.size field which returns number.max field which returns a number also.From the above values, the autoIndexed is deprecated from MongoDB version 3.4 and 3.2. We are using MongoDB version ... Read More
97 Views
To drop a database in MongoDB, you need to use dropDatabase() method. The syntax is as follows:db.dropDatabase()The above syntax will delete the present working database. If you haven’t selected any database then it will delete the default database.Before deleting the database, first list all the databases with the help of show command. The query is as follows:> show dbs;The following is the output:admin 0.000GB config 0.000GB local 0.000GB sample 0.000GBHere, let us delete the database ‘sample’. To delete the database ‘sample’, you need to switch the database with the help of use command. The syntax is as follows:use yourDatabaseName;The query ... Read More
216 Views
To create a new database in MongoDB, you need to use the ‘use’ command. The syntax is as follows:use yourDatabaseName;The above syntax will create a new database in MongoDB. If the database name is already present then it will return the database name. Here, I am going to create a database with the name ‘sample’.The query to create a database in MongoDB is as follows -> use sample; switched to db sampleNow to check the present working database name you need to use the following syntax:dbThe query is as follows:> db sampleTo list all database names in MongoDB, you need ... Read More
457 Views
BigData and NoSQL are the choice for database solutions nowadays, but that does not mean the crucial features of RDBMS will die. Since 90% of the world data produced in last some years, therefore the need for RDBMS will not end in the near future.The RDBMS market is incrementing with 9% annual growth, as stated by Gartner, a research company. RDBMS is meant to handle organized data. NoSQL and Big Data maybe a preferred choice, but the importance of RDBMS will not end in near future.Managing data on a large scale now needs technologies like Big Data, but RDBMS still ... Read More