MongoDB Drop DataBase

The MongoDB drop database statement is used to drop an exiting database. It does not require specifying the database name, because by default the command removes the currently selected database.

Drop DataBase Syntax :

The syntax of the Drop DataBase is −

db.dropDatabase()


Drop DataBase Example :

The Example of the Drop DataBase is −

\\ the list of databases
> show dbs
admin          0.000GB
mydb           0.000GB
local          0.000GB


-------------------
-------------------


\\ Switch to the database

> use mydb
switched to db mydb


-------------------
-------------------

\\ command db.dropDatabase() would delete this database

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

-------------------
-------------------

\\verify that the database is deleted successfully

> show dbs
admin          0.000GB
local          0.000GB
 




Visit :


Discussion


* You must be logged in to add comment.