MongoDB Drop Collection | drop() Method In MongoDB In Hindi

📔 : MongoDB 🔗

आपने MongoDB में collections को create और use करना सीखा , इस topic में हम collection को drop / delete करना सीखेंगे ।

MongoDB drop() Method

MongoDB में drop() method एक database या collection को हमेशा के लिए delete करने के लिए use होता है। इस method का use करके आप MongoDB database में stored collection को drop / delete करते हैं।

यह SQL की DROP statement की तरह ही है।

MongoDB drop() Syntax
db.collectionName.drop()

यहां collectionName की जगह आप अपना collection का नाम दें जिसे delete करना है।

drop() method का use करने से पहले ध्यान रहे कि इससे data हमेशा के लिए delete होगा। और recover करना मुश्किल हो सकता है अगर आपके पास backup नहीं है।

MongoDB drop() Example

Suppose आपके पास एक "employees" collection है जिसे drop करना है। हालाँकि आप show collections command run करके देख सकते हैं कि कौन कौन से collections आपके database में हैं।

show collections

इस command से सभी collections दिख जायेंगे हाँ जिनमे data नहीं होगा वो list नहीं होंगे।

delete colelction

db.employees.drop();

तो कुछ इस तरह MongoDB में collections को drop करते हैं।

Delete documents from collection . .

Related Topics :

Rahul Kumar

Rahul Kumar

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

b2eprogrammers