Mongodb 建立索引

来源:互联网 发布:泰国出行必备软件 编辑:程序博客网 时间:2024/05/16 15:44

1.建立索引

1.1.普通索引

> db.person.ensureIndex({age:1});{        "createdCollectionAutomatically" : false,        "numIndexesBefore" : 1,        "numIndexesAfter" : 2,        "ok" : 1}

1.2.唯一索引

> db.person.ensureIndex({age:1},{unique:true});{        "createdCollectionAutomatically" : false,        "numIndexesBefore" : 1,        "numIndexesAfter" : 2,        "ok" : 1}

2.删除索引

> db.person.dropIndex({age:1});{ "nIndexesWas" : 2, "ok" : 1 }


0 0
原创粉丝点击