Navigation

drop

On this page

  • Syntax
  • Parameters
  • Output
  • Examples
  • Drop Collections Examples
  • Drop Views Example
  • Troubleshoot Errors

The drop command removes the specified collection or view from the Atlas Data Lake storage configuration. Use the wildcard "*" to remove all collections generated by the wildcard collection function (that is, collectionName()), including the wildcard collection rule itself. You cannot individually remove collections generated by the wildcard collection function.

The following examples use the drop command to remove sample collections that were mapped to the sample dataset, airbnb and weather, in the AWS S3 store.

The following example uses the drop command to remove a sample collection named airbnb in a database named sample in the storage configuration.

use sample
db.runCommand({ "drop" : "airbnb"})

The previous command prints the following output:

{ "ok" : 1, "ns" : "sample.airbnb", "nIndexesWas" : 0 }

The following example uses the drop command to remove the wildcard collection function (collectionName()) and all collections created by the wildcard collection function in a database named sample in the storage configuration.

use sample
db.runCommand ({ "drop" : "*" })

The previous command prints the following output:

{ "ok" : 1, "ns" : "sample.*", "nIndexesWas" : 0 }

The following command removes a view named "listings" on the airbnb collection in the sample database:

use sample
db.runCommand({ "drop" : "listings" })

The previous command returns the following output:

Example
{ "ok" : 1, "ns" : "sample.listings", "nIndexesWas" : 0 }

If the command fails, it returns one of the following errors.

Reason: Namespace (database, collection, or view) does not exist.

{
ok: 0,
errmsg: "ns not found",
code: 26,
codeName: "NamespaceNotFound"
}

Solution: Ensure that the namespace specified in the command is valid and exists in the storage configuration. If necessary, use the getStorageConfig command to retrieve the list of valid databases, collections, and views in the storage configuration.

Reason: Attempting to remove a collection created by the wildcard collection function (collectionName()).

{
ok: 0,
errmsg: "cannot drop a collection created from a wildcard",
code: 26,
codeName: "NamespaceNotFound"
}

Solution: Ensure that the collection you are dropping is not an individual collection dynamically generated by the wildcard collection function (collectionName()). Data Lake does not support dropping individual collections generated by the wildcard collection function.

Give Feedback

On this page

  • Syntax
  • Parameters
  • Output
  • Examples
  • Drop Collections Examples
  • Drop Views Example
  • Troubleshoot Errors