Read Time:24 Second
Create a New Database and Collection
To create a new database, issue the use <db>
command with the database that you would like to create. For example, the following commands create both the database myNewDatabase
and the collection myCollection
using the insertOne()
operation:
use myNewDatabase db.myCollection.insertOne( { x: 1 } );
If a collection does not exist, MongoDB creates the collection when you first store data for that collection.
Average Rating