MongoDB | 2. 集合(表)操作

2020-12-31  本文已影响0人  ShadowFieldEric

查看集合(表)

> show collections
demo_collection

> show tables
demo_collection

创建集合(表)

  1. 直接插入数据创建
> db.demo_collection.insert({"name" : "Eric"})
WriteResult({ "nInserted" : 1 })
> show tables
demo_collection
  1. 使用系统方法创建
> 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
上一篇 下一篇

猜你喜欢

热点阅读