[MongoDB] Mongo 表字段添加索引, 查看索引, 刪除索引


通過llama.cpp與羊駝聊天的網頁界面- 詳解 Serge 的啟動使用

 

查看索引:

db.getCollection('xx').getIndexes();

 

創建索引:

# 1 代表升序,-1代表降序,name 指定索引名

db.getCollection('xx').createIndex( {"title": 1}, {"name":"idx_xxx"} );

 

創建復合索引:

db.getCollection('xx').createIndex( {"title": 1, "created_at": -1} );

 

內嵌字段創建索引:

db.集合名.createIndex( {"字段名.內嵌字段名":1}, {"name":'idx_字段名_內嵌字段名'} )

 

刪除索引:

db.getCollection('xx').dropIndex("idx_xxx");

 

Ref:https://www.runoob.com/mongodb/mongodb-indexing.html

https://www.cnblogs.com/xuliuzai/p/9965229.html

Link:https://www.cnblogs.com/farwish/p/14817554.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM