← Back to MongoDB Course | Chapter 5: CRUD — Delete | Lesson 5 of 6

Database Drop करना

dropDatabase current database और इसके अंदर हर collection remove करता है।

In this page:

  1. Drop Database
Syntax
javascript
use database_name
db.dropDatabase()

Drop Database

db.dropDatabase() वह database delete करता है जो आप currently इस्तेमाल कर रहे हैं, सारी collections, indexes, और data समेत। यह tests और resets के लिए है। पहले db.getName() से double check करें, और एक verified backup के बिना इसे कभी production पर न चलाएँ।

Note: यह confirm करने के लिए db.getName() चलाएँ कि आप कौन-से database पर हैं।

उदाहरण: Drop database

bash
test> use scratch
switched to db scratch
scratch> db.getName()
scratch
scratch> db.dropDatabase()
{ ok: 1, dropped: 'scratch' }

⚠️ Run this in your own terminal or Node.js environment.

Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. गलत database पर इसे चलाना
  2. कोई backup न होना
  3. habit से इसे production पर करना
चैप्टर सारांश
  • dropDatabase current database में सब कुछ delete करता है
  • पहले db.getName() check करें
  • Backups के बिना irreversible
  • Test resets के लिए ideal
🔒

Chapter Quiz — Complete all 6 topics to unlock

0/6 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.