how to drop collection in mongodb


How to drop collection in mongodb

drop() method is use to drop collection in Mongodb.

drop() method returns true if collection will be dropped.if collection is not exists in Mongodb then it will return false.

Syntax

db.Collection_Name.drop()

Connect to DB

>use demo
Switched to db demo

Show All Collections

>show collections
stud
Emp   

Drop Collection in mongodb

>db.Emp.drop()
true

Note.

Here Emp is collection name

Show Collections

>show collections
stud

Please observe Emp Collection droped here.






Full-stack web and mobile app development company Contact Us : Skype: indore.webcoder Email: info@w3sparks.com Sales: +91 8085506229