w3resource

MongoDB: db.dropDatabase() method

db.dropDatabase

The db.dropDatabase() method is used to remove the current database along with the associated data files.

Syntax:

db.dropDatabase()

Example: MongoDB: db.dropDatabase() method

Here is the databases.

> show dbs
admin    0.078GB
local    0.078GB
myinfo   0.078GB
newtest  0.078GB
payroll  0.078GB
test     0.078GB

The following example will drop the database newtest.

db.dropDatabase();

Output:

> db.dropDatabase();
{ "dropped" : "newtest", "ok" : 1 }

Now list the databases : 

> show dbs 
admin    0.078GB
local    0.078GB
myinfo   0.078GB
payroll  0.078GB
test     0.078GB

Retrieve the restaurants data from here

Previous: db.currentOp() method
Next: db.fsyncLock() method



Follow us on Facebook and Twitter for latest update.