If tutorials available on this website are helpful for you, please whitelist this website in your ad blocker😭 or Donate to help us ❤️ pay for the web hosting to keep the website running.
पिछले topic में आपने MongoDB में collections को drop करना सीखा , इस topic में हम database को drop / delete करना सीखेंगे ।
MongoDB में database को drop (delete) करने के लिए db.dropDatabase()
method का use किया जाता है।
MongoDB में Database को delete करने के लिए आप नीचे दिए गए steps follow कर सकते हैं -
1. Connect MongoDB Server : अगर आपने MongoDB server से connect नहीं किया है तो terminal या command prompt को open करें और MongoDB shell को mongo
type करके Enter press करें। ध्यान रहे कि आपके पास database को drop करने के लिए permissions होनी चाहिए।
2. Switch Database : Database को drop करने से पहले use
command का use करके उस database में switch करें जिसे आप drop करना चाहते हैं।
use YourDatabaseName
3. Drop Database : finally database switch करने के बाद आप db.dropDatabase()
method का use करके delete कर सकते हैं।
db.dropDatabase()
4. Confirmation : MongoDB database को drop करके एक response return करेगा कि database delete हो गया है।
> use mytestdb switched to db mytestdb > db.dropDatabase() { "dropped" : "meradatabase", "ok" : 1 }
इस command का use सावधानी से करें , खासकर production environment में क्योंकि database को drop करने से complete data delete हो जायगा। तो जब भी किसी database को drop करें तो check कर लें कि उसका backup आपके पास है।
●●●
Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)
Get connected with me. :) LinkedIn Twitter Instagram Facebook