In MongoDB, db.collection.drop() method is used to drop a collection from a database. It completely removes a collection from the database and does not leave any indexes associated with the dropped collections.
The db.collection.drop() method does not take any argument and produce an error when it is called with an argument. This method removes all the indexes associated with the dropped collection.
MongoDB Drop collection example
Let’s take an example to drop collection in MongoDB.
First check the already existing collections in your database.
- >use mydb
Switched to db mydb
- > show collections
Note: Here we have a collection named SSSIT in our database.
Now drop the collection with the name SSSIT:
Now check the collections in the database:
- >show collections
Now, there are no existing collections in your database.