1.根据某个字段建唯一索引,去掉重复的文档
db.collection.ensureIndex( { column1:1, column2:1 }, { unique:true, dropDups:true }
2.导出集合
mongoexport -d test -c students -o students.json
3.导入集合
mongoimport -d test -c students students.json
1.根据某个字段建唯一索引,去掉重复的文档
db.collection.ensureIndex( { column1:1, column2:1 }, { unique:true, dropDups:true }
2.导出集合
mongoexport -d test -c students -o students.json
mongoimport -d test -c students students.json
【mongo 系列】mongodb 學習六,索引淺析 阿兵雲原生 2021-10-07 1,787 閱讀5分鐘 專欄: 開源組件專題