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分鐘 專欄: 開源組件專題