English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
In this chapter, we will see how to use MongoDB to delete a collection.
db.collection.drop()Used to delete a collection from the MongoDB database.
drop()The basic syntax of the command is as follows-
db.COLLECTION_NAME.drop()
First, check in the available collections into the databasemydb.
>use mydb switched to db mydb >show collections mycol mycollection system.indexes w3codebox >
Now delete the collection named mycollection collection.
>db.mycollection.drop() true >
Check the list of collections collected in the database again.
>show collections mycol system.indexes w3codebox >
If the selected collection is successfully deleted, the drop() method will return true; otherwise, it will return false.