View Databases
show dbs command lists all databases and their storage sizes. System displays admin, local, config three databases by default.
Switch Databases
use database_name is used to switch or create a database. If the database does not exist, MongoDB will automatically create it when data is first written.
Create Collection
db.createCollection(name, options) is used to create a collection.
Optional parameters:
- capped: Fixed collection
- size: Maximum size
- max: Maximum number of documents
View Collections
show tablesshow collections
Delete Collection
db.collection_name.drop() deletes the specified collection and all its data. Returns true on success, false if it does not exist.
Delete Database
db.dropDatabase() deletes the current database and all its collections and documents.