MongoDB Delete Collection

Copyright, without permission, is prohibited reprint

chapter


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 mydball 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.

Guess you like

Origin www.cnblogs.com/jinbuqi/p/11274496.html