In MongoDB, db.collection.drop()
method is used to drop a collection from a database. It completely removes a
collection from the database and does not leave any indexes associated with the
dropped collections.The db.collection.drop() method does not take any argument
and produce an error when it is called with an argument. This method removes
all the indexes associated with the dropped collection.
The drop() MethodMongoDB's
db.collection.drop() is used to drop a collection from the database.
Syntax
Basic syntax of drop() command is
as follows –
db.COLLECTION_NAME.drop()
It Removes a collection or view from
the database. The method also removes any indexes associated with the dropped
collection. The method provides a wrapper around the drop command.
Example
The following operation drops the employee
collection in the current database.
db. employee.drop()
MongoDB Drop collection example
>db.mycollection.drop()
true
>
Now check the list of
collections in the database.
>show collections
mycol
system.indexes
tutorialspoint
>
In MongoDB, db.collection.drop()
method is used to drop a collection from a database. It completely removes a
collection from the database and does not leave any indexes associated with the
dropped collections.The db.collection.drop() method does not take any argument
and produce an error when it is called with an argument. This method removes
all the indexes associated with the dropped collection.
The drop() MethodMongoDB's
db.collection.drop() is used to drop a collection from the database.
Syntax
|
Basic syntax of drop() command is
as follows –
db.COLLECTION_NAME.drop()
|
It Removes a collection or view from
the database. The method also removes any indexes associated with the dropped
collection. The method provides a wrapper around the drop command.
Example
The following operation drops the employee
collection in the current database.
db. employee.drop()
MongoDB Drop collection example
|
>db.mycollection.drop()
true
>
|
|
Now check the list of
collections in the database.
>show collections
mycol
system.indexes
tutorialspoint
>
|