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:

snippet
db.dropDatabase()

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:

snippet
>show dbs
Output
javatpointdb 0.078GB local 0.078GB

If you want to delete the database "javatpointdb", use the dropDatabase() command as follows:

snippet
>use javatpointdb
Output
switched to the db javatpointdb
snippet
>db.dropDatabase()
Output
{ "dropped": "javatpointdb", "ok": 1}

Now check the list of databases:

snippet
>show dbs
Output
local 0.078GB
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents