执行脚本创建表,建立索引
var mvnoCodeArray=new Array("12312323");
var yearPreArray = new Array("2016_10","2016_11","2016_12","2017_1");createIndexes(mvnoCodeArray,yearPreArray);
function createIndexes(code,yearPre){
for (var j=0; j < code.length; j++) {
for (var i=0; i < yearPre.length; i++) {
var tableName = "FLOW_"+mvnoCode[j]+"_"+yearPre[i];
db[tableName].insert({
"serialNumber" : "7c6b3dds343439b0138209292ded31d17c15",
"createDate" : NumberLong("1474526220000"),
"userName" : "1@163.com",
});
db[tableName].ensureIndex({"createDate":1},{background:true});
db[tableName].ensureIndex({"userName":1},{background:true});
db[tableName].remove({"serialNumber" : "7c6b3dds343439b0138209292ded31d17c15"},{background:true});
}
}
}
然后执行如下命令即可
./mongo localhost:40000/mongodb -usite -p --authenticationDatabase admin /usr/local/mongodb/bin/indexes.txt