How to Drop a MongoDB Collection Easily
Q: What is the syntax to drop a collection in MongoDB?
- MongoDB
- Mid level question
Explore all the latest MongoDB interview questions and answers
ExploreMost Recent & up-to date
100% Actual interview focused
Create MongoDB interview for FREE!
The syntax to drop a collection in MongoDB is the "db.collection.drop()" method. This method is used to delete a collection from the database.
To use this method, you need to follow these steps:
1. Connect to the MongoDB database using the MongoDB client.
2. Select the database you want to use with the "use" command.
3. Fire the db.collection.drop() command in the MongoDB shell.
For example:
use mydatabase
db.mycollection.drop()
This command will drop the collection called "mycollection" from the database "mydatabase".
It is important to note that the drop() method will only work if the collection exists in the database. If the collection does not exist, then the command will return an error.
To use this method, you need to follow these steps:
1. Connect to the MongoDB database using the MongoDB client.
2. Select the database you want to use with the "use" command.
3. Fire the db.collection.drop() command in the MongoDB shell.
For example:
use mydatabase
db.mycollection.drop()
This command will drop the collection called "mycollection" from the database "mydatabase".
It is important to note that the drop() method will only work if the collection exists in the database. If the collection does not exist, then the command will return an error.


