In this article, we learn MongoDB Drop collection. My main focus describes its simple steps. Drop statement<db.collection.drop()> is used to delete the table and also delete it’s all the data as well from a database. You will delete existing collection in the database.
The following is a basic syntax-
- <db> is a reserved word.
- <Drop> is also a reserved word used for drop collection.
- <Collection_name> selected collection name which you want to remove.
Drop a collection-:
First, we find the available list of a collection that exists in a database.
> use logs
switched to db logs
> show collections
First, we will use command name<show collections> and check the existing database.
Now we remove collection name like <programmerhelper>.the following query is used to drop a database-
Drop method will return true if it deleted the selected collection.otherwise its return false.you will see both works below a fig.first time I drop <programmershelper> collection its return <true> result. Second time again repeat that work and result give <false>.
Now check again a list of collection.the following command is used-
I wish I could tell you that a great site of MongoDB. You just understands the key element above post-MongoDB Drop collection. You also read my previous lecture. I hope you will understand this lecture. Thank you for reading this lecture. Hope you got the idea. please share it.