1. Home
  2. MongoDB
  3. MongoDB Tutorial
  4. MongoDB – Drop Collection

MongoDB – Drop Collection

MongoDB Drop Collection

Use db.collection.drop() statement to delete existing collection. The result will be true on successful deletion.

Syntax

> db.COLLECTION_NAME.drop()

First, use below commands to select the database and list available collections.

> use mydb
> show collections

tecadmin
accounts
mycol

MongoDB Drop Collection

Finally, delete the collection named tecadmin using below methods from the mydb database.

> db.tecadmin.drop();

true

Also, you can also use drop() method with getCollection() to remove existing collection as following.

> db.getCollection("tecadmin").drop();

true