Shoken Startup Blog

KitchHike Founder/CTO

MongoDBでcollectionを削除する方法

MongoDBでコレクションを削除するにはdrop()を使います。

[root@xxx ~]# mongo
MongoDB shell version: 2.4.5
connecting to: test

> db.students.insert({"name":"shoken"}) ## studentsコレクションを作成
> show collections
students
system.indexes
> db.students.drop()
true
> show collections
system.indexes            ## studentsコレクションが削除されている