Search⌘ K
AI Features

Creating Databases and Collections

Explore how to create databases and collections in MongoDB, insert single or multiple documents, and understand how MongoDB automatically manages collections. This lesson helps you build foundational skills for managing data using CRUD operations.

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 ...