Search⌘ K
AI Features

Creating Databases and Collections

Explore how to create and manage databases and collections in MongoDB. Learn to insert single and multiple documents, understand automatic collection creation, and verify your data setup. This lesson builds foundational skills for effective data management using MongoDB.

A database in MongoDB is a container for collections, and a collection contains a group of documents. Before we can store data, we first need to create these structures.

Creating a database and collection

We don't need a special command to create a database in MongoDB. Simply, switch to a new database name using the use command as follows:

Assembly (GAS x86)
use myNewDatabase

Remember that ...