In this post, we will see how to drop a collection using MongoDB.
MongoDB's db.collection.drop() is used to drop a collection from the database.
Basic syntax of drop() command is as follows −
db.COLLECTION_NAME.drop()
First, check the available collections into your database mydb.
> show collections mycollection posts
Now drop the collection with the name mycollection.
> db.mycollection.drop() true
Again check the list of collections into database.
> show collections posts
drop() method will return true, if the selected collection is dropped successfully, otherwise it will return false.
There was an error while loading. Please reload this page.