Introduction
In this article, we learn MongoDB Drop database.My main focus describes its simple steps. Drop database statement<db.dropDatabase()> is used to remove existing database.If you want to drop a database be careful.In the case of drop database, all the necessary information will be lost.
Prerequisite
You should also read my previous articles.In which I explained MongoDB update document step by step guidelines and MongoDB create a database step by step guideline
Implementation Section
- db.dropDatabase
The following is a basic syntax-
1 | db.dropDatabase() |
- <db> is a reserved word.
- <dropdatabase> is also reserved word used for drop database.
Practical work
<dropdatabase>statment will remove the selected database. if we not selected any database by default<Test> database will be deleted.
First, we will use command name<show db> and check the existing database.
1 | show dbs |
output:
These are many existing databases that I created. I selected any one and drop a database.SO I selected<cricket> and drop that one.
The following query is used to drop a database-
1 2 3 | > use cricket > switched to db cricket > db.dropDatabase() |
Output
Now check again a list of database.
The following command is used-
1 | show dbs |
output:
The the following fig you will see <cricket database> is not showing.
I wish I could tell you that a great site of MongoDB.you just understands key element above post-MongoDB Drop database.You also read my previous lecture.I hope you will understand this lecture.Thank you for reading this lecture. Hope you got the idea. please share it.