MongoDB — Databases
Create Database
use mydb
List Databases
show dbs
Current Database
db
Drop Database
use mydb
db.dropDatabase()
Database Properties
// Get database stats
db.stats()
Use Database
// Switch to database
use mydb
// If doesn't exist, creates on first insert
Database Commands
| Command | Description |
|---|---|
| show dbs | List databases |
| use db | Switch database |
| db | Current database |
| db.dropDatabase() | Drop database |
| db.stats() | Database statistics |
Mini Practice
- Create a database
- List all databases
- Check current database
- Drop a database
Up Next
Continue with Create Database — creating databases.
Related Topics
Frequently Asked Questions about Databases
What is Databases in MongoDB?
Databases is a fundamental concept in MongoDB. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn Databases?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Databases.
Why is Databases important in MongoDB?
Databases is essential for MongoDB development. Understanding this concept will help you write better code and solve real-world problems more effectively.