mongo细节

mongo创建表
db
.createCollection(name, {capped: <Boolean>, autoIndexId: <Boolean>, size: <number>, max: <number>} )
db.createCollection(name, {capped: <Boolean>, autoIndexId: <Boolean>, size: <number>, max: <number>} )
name: collection名称,相当于mysql中的table
capped:如果为true,则如果表的大小超过指定的上限时,新增的记录会覆盖old记录,且,如果为true,则必须指定size大小;如果为false,那么新建的collection是一个普通的collection;
autoIndexID:为true自动生成_id字段,为false则禁止自动生成_id字段
size:单位是bytes,如果为capped collection,size为该capped collection所能拥有的最大硬盘空间;否则该字段为普通collection预分配的存储空间
max:该collcetion能拥有的最大条目数,the maximum number of documents(相当于mysql中定义的一个表中最多有多少条record)

 

 

posted on 2013-10-30 10:48  awildfish  阅读(263)  评论(0编辑  收藏  举报

导航