Use command
MongoDB creates a database in the same way as use + database name. Use creates a new database and returns the database if it exists.
Syntax format
The basic format of the use statement is as follows:
Use database_name
Example
Create a database named, using the USE statement as follows:
>use MyDB
Switched to DB MyDB
Use the command DB to check the currently selected database.
>db
MyDB
Use the command show DBS to check the database list.
>show DBS
Local 0.78125GB
Test 0.23012GB
The database you just created (mydb) does not appear in the list. In order for the database to appear, at least one document should be inserted.
>db.mydb.insert ({"Name": "Tutorials Point"})
>show DBS
Local 0.78125GB
MyDB 0.23012GB
Test 0.23012GB
In MongoDB, the default database is test, and if you do not create any databases, the collection is saved in the test database.
MongoDB Database Creation