MongoDB Drop Database - MongoDB

How to drop a database in MondoDB?

In this chapter, we will explain how to drop a database using MongoDB command.

dropDatabase() Method

MongoDB db.dropDatabase() command is used for dropping an existing database.

Syntax

Basic syntax of dropDatabase() command is as follows

This deletes the selected database. If no database is selected, then it will delete default 'test' database.

Example

First, check the list of available databases by using the command, show dbs.

To delete the new database <mydb>, then dropDatabase() command would be as follows

Now check list of databases.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

MongoDB Topics