Delete the database MongoDB
grammar
MongoDB database delete syntax is as follows:
db.dropDatabase()
Delete the current database, the default for the test, you can use db command to view the current database name.
Examples
The following example we removed the database w3big.
First, check all databases:
> show dbs local 0.078GB w3big 0.078GB test 0.078GB
Then we switch to the database w3big:
> use w3big switched to db w3big >
Delete command:
> db.dropDatabase() { "dropped" : "w3big", "ok" : 1 }
Finally, we show dbs command through the database deleted successfully:
> show dbs local 0.078GB test 0.078GB >
Delete Collection
Collection delete syntax is as follows:
db.collection.drop()