查看集合(表)
> show collections
demo_collection
> show tables
demo_collection
创建集合(表)
- 直接插入数据创建
> db.demo_collection.insert({"name" : "Eric"})
WriteResult({ "nInserted" : 1 })
> show tables
demo_collection
- 使用系统方法创建
> db.createCollection("runoob")
{ "ok" : 1 }
> show tables
demo_collection
runoob
> db.createCollection("mycol", { capped : true, autoIndexId : true, size : 6142800, max : 10000 })
{
"note" : "The autoIndexId option is deprecated and will be removed in a future release",
"ok" : 1
}
删除集合
> db.test.drop()
true
网友评论