MongoDB Drop collection
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.
Switched to db mydb
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:
Now, there are no existing collections in your database.
Note: The drop command returns true if it successfully drops a collection. It returns false when there is no existing collection to drop.