Copyright, without permission, is prohibited reprint
chapter
- Getting Started with MongoDB
- MongoDB advantage
- MongoDB installation
- MongoDB Data Modeling
- Create a database MongoDB
- Delete the database MongoDB
- Create a collection MongoDB
- MongoDB Delete Collection
- MongoDB data type
- MongoDB into the document
- MongoDB query document
- MongoDB document update
- MongoDB delete documents
- MongoDB Projection
- MongoDB Limit
- MongoDB sort
- MongoDB index
- MongoDB aggregation
- MongoDB data backup
This chapter describes how to remove the collection in MongoDB.
drop () method
drop()
The method used to remove the set from the database.
grammar
drop()
The basic syntax of the command is as follows
db.COLLECTION_NAME.drop()
example
First, display the database mydb
all set.
> use mydb
switched to db mydb
> show collections
mycollection
mycollection2
mycollection3
qikegu
Now delete the collection named mycollection2.
> db.mycollection2.drop()
true
The set list to check the database again.
> show collections
mycollection
mycollection3
qikegu
If the collection is successfully removed, drop()
the method returns true, otherwise false.