MongoDB deletes the database
Grammar
MongoDB deletes the database in the following syntax format:
db.dropDatabase()
Delete the current database, which defaults to test, and you can use the db command to view the current database name.
Instance
The following example we deleted the database youj.
First, look at all the databases:
> show dbs local 0.078GB youj 0.078GB test 0.078GB
Next we switch to database youj:
> use youj switched to db youj >
To execute a delete command:
> db.dropDatabase() { "dropped" : "youj", "ok" : 1 }
Finally, let's go through show dbs to command whether the database was deleted successfully:
> show dbs local 0.078GB test 0.078GB >
Delete the collection
The collection deletion syntax format is as follows:
db.collection.drop()