索引的创建
创建索引 createIndex() 方法
3.0.0 版本之前使用 ensureIndex() 方法创建索引,之后的版本用 createIndex(),ensureIndex() 还能用,但只是 createIndex() 的别名
db.collection.createIndex(keys, options)
db.collection.ensureIndex()
索引的重建
重建已存在的索引 reIndex() 方法
索引的查看
查看集合的所有索引
db.collection.getIndexes()
查看集合索引的总大小
totalIndexSize()
查看数据库中所有索引信息
db.system.indexes.find()
索引的删除
删除指定的索引
dropIndex()
db.collection.dropIndex("INDEX-NAME")
删除所有索引
dropIndexes()
db.collection.dropIndexes()