Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

MongoDB – Drop Collection

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The drop() method removes collections from the database. It also removes all indexes associated with the dropped collection. The drop method accepts an optional document. It returns true if the collection dropped successfully. It takes one parameter which is optional.

  • This method creates an invalidate Event for any change streams opened for dropped collection.
  • This method obtains an exclusive lock on the given collection for the duration of the operation. Till then all the subsequent operations must wait for the drop() method to release the lock.


db.Collection_name.drop({writeConcern: <document>})


It does not take any parameter.

Optional Parameters:

This parameter is a document expressing the write concern of the db.collection.drop() operation. It is used when we want to omit to use of the default write concern.


This method returns true when successfully drops a collection, otherwise returns false.

Example 1 :

In the following example, we are working with:

Database: gfg

Collection: student

Document: Three documents contains name and the age of the students

We have student collection in the gfg database, and we want to drop it when we give commend:


It drops the student collection and all the indexes associated with the collection:

Example 2:

In the following example, we are working with:

Database: gfg

Collections: student_gfg, teacher, semester

Here, we want to drop teacher collection from the gfg database. So, we use drop method:


This method drops teacher collection along with its documents.

My Personal Notes arrow_drop_up
Last Updated : 28 Jan, 2021
Like Article
Save Article
Similar Reads
Related Tutorials