索引的創建
創建索引 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()