Home » MongoDB Drop Database

MongoDB Drop Database

by Online Tutorials Library

MongoDB Drop Database

The dropDatabase command is used to drop a database. It also deletes the associated data files. It operates on the current database.

Syntax:

This syntax will delete the selected database. In the case you have not selected any database, it will delete default “test” database.

To check the database list, use the command show dbs:

tutoraspiredb 0.078GB local 0.078GB 

If you want to delete the database “tutoraspiredb”, use the dropDatabase() command as follows:

switched to the db tutoraspiredb 
{ "dropped": "tutoraspiredb", "ok": 1} 

Now check the list of databases:

local 0.078GB 

You may also like