Drop Collection
MongoDB 的 db.collection.drop() 用於從資料庫中刪除集合。
首先,檢查可用的集合到你的資料庫 mydb。
> use mydb
switched to db mydb
> show collections
newCollection1
newCollection2
newCollection3
system.indexes
現在刪除名為 newCollection1 的集合。
> db.newCollection1.drop()
true
注意: 如果集合成功下載,則該方法將返回 true,否則將返回 false。
再次檢查集合列表到資料庫中。
> show collections
newCollection2
newCollection3
system.indexes
參考: MongoDB drop() 方法。