The best Delete the database MongoDB Tutorial In 2024, In this tutorial you can learn Delete the database MongoDB
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.
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 >
Collection delete syntax is as follows:
db.collection.drop()