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
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/mongodb/shell-methods/database/db-dropDatabase.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics