/    /  MongoDB – Drop Collection

MongoDB – Drop Collection:

In this tutorial, we will learn about how to drop a collection in MongoDB. In mongoDB, we can drop collections by using the below syntax.

Syntax:db.collection_name.drop()

Example:

Use the test database and verify the already existing collections in your DB.

testset:PRIMARY> use test
switched to db test
testset:PRIMARY>db
test
testset:PRIMARY> show collections
i2tutorial
imongo
mycollection
system.indexes

Drop the collection imongo and verify if the deleted collection existing or not.

testset:PRIMARY>db.imongo.drop()
true
testset:PRIMARY> show collections
i2tutorial
mycollection
system.indexes