The dropDatabase command removes the specified database from the storage configuration. If you drop a database that contains one or more collections, the collections are also removed from the storage configuration.

db.runCommand({ "dropDatabase": 1 })
The flag to pass when dropping a database from the storage configuration.

The command prints the following output if the command succeeds. To check whether the database was dropped from the storage configuration, run the show dbs and storageGetConfig commands. If the command prints errors, see Troubleshoot Errors below for recommended solutions.

{ "ok" : 1, "dropped" : "<database>" }

where <database> is the name of the database that was dropped from the storage configuration.

If there is no active database to drop and therefore no database was dropped, the command returns the following output:

{ "ok" : 1 }

The following example uses the dropDatabase command to drop a database named egS3Store from the Atlas Data Lake storage configuration.

use egS3Store
db.runCommand({ "dropDatabase": 1 })

The previous command prints the following output:

{ "ok" : 1, "dropped" : "egS3Store" }

If the command fails, it prints the following error:

ok: 0,
errmsg: “have to pass 1 as db parameter”,
code: 20,
codeName: "IllegalOperation"

Solution: Specify 1 as the parameter to the command.

Give Feedback
←  dropdropStore →