Mongodb Drop Collection

By Yashwant Chavan, Views 1078, Date 18-Oct-2016

In this tutorial we will learn how to drop mongoDB collection from the database.

tags mongodb

mongoDB Drop Collection - db.collection.drop()

mongoDB removes a collection from the database. It also removes all the indexes which is associated with the dropped collection. Refer following drop() method syntax.

db.collection.drop()

It will return true when successfully drops a collection from the database otherwise return false. The following example we will drop the animals collection from the technicalkeeda database.

> use technicalkeeda
switched to db technicalkeeda

> show collections
animals
logs
persons
profiles
system.indexes

> db.animals.drop();
true

Verify the drop() method output. Use show collections to list of collections into database.

> show collections
logs
persons
profiles
system.indexes
>
Yashwant Chavan

Yashwant Chavan

Hi there! I am founder of technicalkeeda.com and programming enthusiast. My skills includes Java,J2EE, Spring Framework, Nodejs, PHP and lot more. If you have any idea that you would want me to develop? Lets connect: yashwantchavan@gmail.com