Easily we can drop collection in mongoDB using drop() command.
Syntax
Using Following syntax you can drop collection in mongoDB.
db.myCollection.drop()
|
Example
Suppose we have a collection "codefari", using following commands you can get a list of the collections of a particular database.
>use mydb
--Result
Switched to db mydb
>show collections
--Result
mycol
codefari
|
Now drop collection by Name
>db.codefari.drop()
Result
true
|
if the result is true it means collection drop successfully.
Again check the list
>show collections
--Result
mycol
|
You can see in above result codefari is missing it means collection "codefari" dropped successfully.