MongoDB: db.collection.drop() method
The db.collection.drop() method is used to removes the specified collection as well as removes any indexes associated with the dropped collection from the database.
db.collection.drop() takes no arguments and will produce an error if called with any arguments.
Example: MongoDB: db.collection.drop() method
Here is the collections in the test database
> show collections restaurants restaurants1 system.indexes user_new userdetails
The following statement will drop the collection user_new.
Here is the output.
Now show the collection list in the test database.
> show collections restaurants restaurants1 system.indexes userdetails
Retrieve the restaurants data from here
This method obtains a write lock on the affected database and will block other operations until it has completed.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join