Navigation
This version of the documentation is archived and no longer supported.

drop

On this page

drop

The drop command removes an entire collection from a database. The command has following syntax:

{ drop: <collection_name>, writeConcern: <document>}

The command takes the following fields:

Field Description
drop The name of the collection to drop.
writeConcern

Optional. A document expressing the write concern of the drop command. Omit to use the default write concern.

When issued on a sharded cluster, mongos converts the write concern of the drop command and its helper db.collection.drop() to "majority".

The mongo shell provides the equivalent helper method db.collection.drop().

Behavior

This command also removes any indexes associated with the dropped collection.

Starting in MongoDB 4.0.2, dropping a collection deletes its associated zone/tag ranges.

Warning

This command obtains a write lock on the affected database and will block other operations until it has completed.

The drop command and its helper db.collection.drop() create an invalidate Event for any Change Streams opened on the dropped collection.

←   currentOp dropDatabase  →