dropIndex() (Drop an Index)

Last updated: 2026-10-09

dropIndex() (Drop an Index)

dropIndex() removes a specific index, accepting its name or key, e.g. `db.users.dropIndex('age_1')`. Dropping an index instantly degrades dependent queries to collection scans, so confirm nothing still uses it before removing it in production. The _id index cannot be dropped.

CategoryIndex & Admin
MongoDB Version1.0+
Example Languagemongosh (Shell)

📝 Syntax

db.<collection>.dropIndex(<indexNameOrKey>)

⚙️ Parameters

index name or keyIndex name (e.g. 'age_1') or key definition (e.g. {age: 1}).

Returns:Result info object (with ok status).

▶ Example

Run the commands below in your local mongosh (requires a running mongod):

// dropIndex: drop the age index by key
db.users.dropIndex({ age: 1 })

Output:

{ ok: 1 }

📌 Notes

📚 Related Tutorials

❓ FAQ

QShould dropIndex take a name or a key?
AEither works: db.users.dropIndex('age_1') or db.users.dropIndex({age: 1}).
QWhat if I drop the wrong index?
ARecreate it with createIndex(). List indexes with getIndexes() before deleting.
QCan dropIndex remove the _id index?
ANo — the _id index is system-managed and cannot be removed.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏