Navigation

drop

drop

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

Changed in version 3.6.

{ drop: <collection_name>, txnNumber: <long>, lsid: { id: <UUID> } }

The command can take the following options:

Option Type Description
txnNumber 64-bit integer/long

Optional.

A strictly increasing non-negative number that uniquely identifies the command in the command’s session.

If specified, the command must also include the lsid option.

New in version 3.6.

lsid Document

Optional.

The document that specifies the unique id of the session associated with the command. If the txnNumber is specified, the lsid is required.

Tip

The mongo shell and the drivers provide helpers to start the session and set the lsid for the commands.

New in version 3.6.

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

Warning

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

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

←   currentOp dropDatabase  →