MongoDB Create Database
Use Database method:
There is no create database command in MongoDB. Actually, MongoDB do not provide any command to create database.
SQL: To create a database, table and insert values in the table manually.
MongoDB: To create a database manually because MongoDB will create it automatically when you save the value into the defined collection at first time.
If there is no existing database, the following command is used to create a new database.
Syntax:
To check the currently selected database, use the command db:
To check the database list, use the command show dbs:
MongoDB Drop Database
The dropDatabase command is used to drop a database,deletes the associated data files.
Syntax:
Now check the list of databases:
MongoDB Create Collection
In MongoDB, db.createCollection(name, options) is used to create collection. But usually you don?t need to create collection. MongoDB creates collection automatically when you insert some documents.
Syntax: