Delete Collection in MongoDB
The db.collection.drop () method in MongoDB is used to delete a Collection from the database.
Drop () method in MongoDB
The db.collection.drop () method in MongoDB is used to delete a Collection from the database.
Syntax
The basic syntax of the drop () command is as follows:
db . COLLECTION_NAME . drop ()
For example
First, you check the available Collections within the mydb database.
> use mydb switched to db mydb > show collections mycol mycollection system . indexes tutorialspoint >
Now, delete the Collection as mycollection as follows:
> db . mycollection . drop () true >
Then, check the Collection again inside the database:
> show collections mycol system . indexes tutorialspoint >
The drop () method will return true, if the selected Collection is successfully deleted, otherwise, it will return false.
According to Tutorialspoint
Previous post: Create Collection in MongoDB
Next lesson: Data type in MongoDB
4 ★ | 2 Vote
You should read it
- Delete Document in MongoDB
- Delete Database in MongoDB
- Overview of MongoDB
- Capped Collection in MongoDB
- Query Document in MongoDB
- MongoDB malicious code attacks more than 26,000 victims in a week
- Learn about security features and authentication in MongoDB
- Index (Mong) in MongoDB
- Reference Database in MongoDB
- Compare the performance of MongoDB and SQL Server 2008
- Advantages of MongoDB
- Create Database in MongoDB
Maybe you are interested
Fix word spacing errors in Word, fix split words and dropped lines
Facebook partner admits to eavesdropping on smartphone microphone conversations for advertising
How to make Excel spreadsheets smarter with drop-down lists
What does Oppo show as a water drop? How to turn off that icon?
There will soon be a file sharing feature between Windows and Android devices similar to AirDrop
Learn about LocalSend: An AirDrop-like app for transferring files between devices wirelessly