您的位置:首页 > 数据库 > Mongodb

mongodb 索引

2016-02-02 11:39 399 查看
mongodb的索引的创建方法;

db.collection.ensureIndex(keys,options) 在mongodb3.0版本后被弃用。

现在是db.collection.createIndex()的别名

db.colleciton.getIndexes()得到collection的所有的索引 () 只能在3.0版本用

For MongoDB 3.0 deployments using the WiredTiger storage
engine, if you rundb.collection.getIndexes() from a version of the mongo shell
before 3.0 or a version of the driver prior to 3.0
compatible version, db.collection.getIndexes() will
return no data, even if there are existing indexes. For more information, see WiredTiger
and Driver Version Compatibility.

得到collection的所有索引:

db.people.getIndexes()


To return a list of all indexes on all collections in a database, usethe following operation in the

mongo shell:

db.system.indexes.find()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: