03
2013-09

mongodb常用操作


作者:容易 2013-09-03 11:01:54



一、数据导入(完成)

mongo -u pnr 192.168.0.10:8010/pnr tRtem.js  -p

mongo -u pnr 192.168.0.10:8010/pnr tProv.js  -p

二、变更

1、collection变更

将原交易集合tScptEvent名称修改为tScEventHis

执行命令:

db.tScptEvent.renameCollection("tScEventHis");


2、新建 tScptEvent 数据集,创建索引

db.tScptEvent.ensureIndex({"eventRefNo":1,"syscode":1},{"name":"eventRefNo_syscode","background":true});

db.tScptEvent.ensureIndex({"custId":1,"requesttime":-1},{"name":"custId_requesttime","background":true});

db.tScptEvent.ensureIndex({"cardNo":1,"requesttime":-1},{"name":"cardNo _requesttime","background":true});

db.tScptEvent.ensureIndex({"pnrDevId":1,"requesttime":-1},{"name":"pnrDevId _requesttime","background":true});

db.tScptEvent.ensureIndex({"cardBin":1,"requesttime":-1},{"name":"cardBin _requesttime","background":true});

db.tScptEvent.ensureIndex({"txDate":1},{"name":"txDate","background":true});

三、数据导出为CSV格式

mongoexport --host 192.168.4.165 --port 27017 -d tiger -u python -p -c thing -f username,user.GlossDiv.title,id  --csv -o  thing1.csv -q '{createtime:{$gt:20130801000000000,$lte:20130809000000000}}'


One Response


    还没有评论!
1  

Leave your comment

请留下您的姓名(*)

请输入正确的邮箱地址(*)

请输入你的评论(*)


感谢开源 © 2016. All rights reserved.&3Q Open Source&^_^赣ICP备15012863号-1^_^
乐于分享共同进步 KreativeThemes