
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Clear a MongoDB Database
To clear, use dropDatabase. Following is the syntax −
use yourDatabaseName; db.dropDatabase();
To clear a MongoDB database, first show all the databases −
> show dbs
This will produce the following output −
MyDB 0.000GB admin 0.000GB config 0.000GB local 0.000GB onlinecustomertracker 0.000GB test 0.006GB
Now, let us delete the database onlinecustomertracker −
> use onlinecustomertracker switched to db onlinecustomertracker > db.dropDatabase(); { "dropped" : "onlinecustomertracker", "ok" : 1 }
Following is the query to show all databases after deleting a database above −
> show dbs
This will produce the following output −
MyDB 0.000GB admin 0.000GB config 0.000GB local 0.000GB test 0.006GB
Advertisements