Drop Collection

to remove the collection from the database through db.collectionName.drop() method.
Syntax:-


db.collectionName.drop()

Note:- if the collection exists then show message true if the collection does not exist then show message false;

Suppose, You have two collections department and employees. Now, check the collections in MongoDB


show collections

Output:-

department
employees

Example:-


db.employees.drop()

Output:-

true

Now get the collection


show collection

Output:-

department