mongodb(2) -索引创建

在shell中查看集合中已经存在的索引,你可以运行:

 

db.things.getIndexes()

 

要查看数据库中所有的索引,可以运行:

 

db.system.indexes.find()

创建索引
db.things.ensureIndex({j:1});


建选项

ensureIndex函数的第二个参数是携带创建选项的文档/对象。这些选项有:

 

选项 默认值
background true/false false
dropDups true/false false
unique true/false false
sparse true/false false
v 索引版本。0=早于v2.0版本,1=更小/更快(当前) 1 in v2.0.除非特殊情境,默认使用1

 

 

http://blog.csdn.net/xinghebuluo/article/details/7221639

 

http://www.cnblogs.com/stephen-liu74/archive/2012/08/01/2561557.html

posted @ 2017-05-15 18:30  超超hd  阅读(143)  评论(0编辑  收藏  举报