Some Useful Command For MongoDB

  Some Useful Command For MongoDB

Useful Commands in MongoDB: 1. MongoDB - Create Database use cscorner 2. If you want to check your databases list, use the command show dbs Your created database is not present in list. To display database, you need to insert at least one document into it 3. MongoDB - Drop Database db.dropDatabase() 4. MongoDB - Create Collection db.createCollection(name) db.createCollection("students") 5. MongoDB-Create Document. db.students.insert({"rollno":1,"name":"sunita"}) If the collection doesn't exist in the database, then MongoDB will create this collection and then insert a document into it. 6. MongoDB -Show Collection show collections 7. MongoDB - Drop Collection db.students.drop() 8. MongoDB - Query Document db.students.find() 9. To display the results in a formatted way, you can use pretty method. db.mycol.find().pretty()



Comments

Popular posts from this blog

Computer Architecture vs Computer Organization