Skip to main content
🎁 Exclusive Launch Deal: Premium Themes Available FREE — Grab Yours Now!
Back to Blog
General

How to drop collection in mongodb

admin 1 min readPublished Dec 3, 2022Updated Jul 22, 2026
How to drop collection in mongodb

When to drop a collection

Dropping a collection permanently removes its documents and indexes. Use it for discarded features, failed experiments, or rebuilding a collection with a new schema. Prefer deleteMany({}) only when you want to keep indexes/collection metadata.

Step-by-step with mongosh

  1. Connect: mongosh "your-connection-uri"
  2. Select DB: use my_app_db
  3. List collections: show collections
  4. Inspect a sample: db.orders.findOne()
  5. Drop: db.orders.drop()
  6. Confirm it returns true and no longer appears in show collections.

Safety checklist before production drops

  • Take a backup or snapshot (mongodump / Atlas backup).
  • Confirm environment (dev vs prod URI).
  • Stop writers that target the collection.
  • Communicate with teammates if the collection is shared.
// Explicit drop
db.getCollection("orders").drop()

// Alternative: wipe documents but keep collection + indexes
db.orders.deleteMany({})

Permissions

Your database user needs privileges to drop collections. In Atlas, restricted users may fail — use a role that includes drop privileges for maintenance windows only.

Recovery notes

After a drop, recovery depends on backups. There is no undo button in mongosh. If you might need the data, archive to another collection or database first: db.orders.aggregate([{ $out: "orders_archive" }]).