MongoShell

Manipulate Database/Collection via mongo shell

Database List

show dbs
  • Use a Database

use test_database
  • Collection list

show collections
# Just insert a document 
db.test_collection.insert({})
# OR create a collection explicitly
db.createCollection("test_collection")
  • Drop a collection

db.test_collection.drop()
  • Drop a database

db.dropDatabase()
  • Others

db.cloneDatabase()
db.cloneCollection()
db.createView()
db.getCollectionsInfos()
db.status()

Last updated