Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (47.6k points)

I'm doing development on MongoDB. For totally non-evil purposes, I sometimes want to blow away everything in a database—that is, to delete every single collection, and whatever else might be lying around, and start from scratch. Is there a single line of code that will let me do this? Bonus points for giving both a MongoDB console method and a MongoDB Ruby driver method. 

2 Answers

0 votes
by (106k points)

For deleting everything in a MongoDB database you can use following queries:-

use [database];

db.dropDatabase();

0 votes
by (108k points)

Just implement the following command:

mongo DATABASE_NAME --eval "db.dropDatabase();"

Related questions

0 votes
2 answers
asked Sep 9, 2019 in SQL by Sammy (47.6k points)
0 votes
1 answer
0 votes
0 answers
0 votes
2 answers
asked Sep 4, 2019 in SQL by Sammy (47.6k points)
0 votes
2 answers

Browse Categories

...