How to Drop collection in MongoDB

You are here : Home / MongoDB Tutorial



Contents of page >
  • 1) First, see list of all tables (collections) in database in MongoDb >
  • 2) How to Drop collection in MongoDb in MongoDb >

1) First, see list of all tables (collections) in database in MongoDb >
> use myb;
switched to db mydb
> show collections
employee
system.indexes
>

2) How to Drop collection in MongoDb in MongoDb >
Here we will drop collection employee
> db.employee.drop();

Now, again see list of all tables (collections) in database in MongoDb >
> show collections
system.indexes
>
You can see that employee collection is dropped.



SUMMARY>
So in this mongoDB tutorial we learned how to Drop collection in MongoDb.
Use db.employee.drop() to drop collection in MongoDb.


Having any doubt? or you liked the tutorial! Please comment in below section.
Please express your love by liking JavaMadeSoEasy.com (JMSE) on facebook, following on google+ or Twitter.



RELATED LINKS>

What is MongoDB - A quick introduction to database


Create new database in mongoDB


Create new collection(table) in mongoDB


Labels: MongoDB
eEdit
Must read for you :