MongoDB creates databases and collections lazily: use blog switches to a database that may not exist yet, and the first insert actually creates it.
mongosh
use blog // switch (nothing created yet)
db.posts.insertOne({ title: "Hello" }) // creates db + collection
show dbs // now 'blog' appears
show collectionsExplicit creation
Use db.createCollection() when you need options like validation rules or capped collections:
mongosh
db.createCollection("logs", {
capped: true, size: 1048576, max: 1000
})Dropping things
db.collection.drop() removes a collection and its indexes. db.dropDatabase() removes the current database. Both are irreversible — there is no undo.