Chinaunix首页 | 论坛 | 博客
  • 博客访问: 191339
  • 博文数量: 43
  • 博客积分: 366
  • 博客等级: 一等列兵
  • 技术积分: 427
  • 用 户 组: 普通用户
  • 注册时间: 2011-10-17 14:03
文章分类

全部博文(43)

文章存档

2018年(2)

2017年(5)

2016年(2)

2015年(3)

2014年(9)

2013年(5)

2012年(8)

2011年(9)

我的朋友

分类: LINUX

2014-08-21 20:13:01

在网上找这种本地移表的方法,一直没找着,自己写了个凑合用~~有时候好不容易写几行基础数据不容易啊,尤其mongodb。。。每次还得带着字段名。。。回头万一设计时候出错了也比较好改~~
下面这种办法会报错:
db.runCommand({cloneCollection:"db1.table_to_move", from:"127.0.0.1:27017"});
{ "errmsg" : "can't cloneCollection from self", "ok" : 0 }

use db1;

var cursor = db.table_to_move.find();

use db2;

while(cursor.hasNext()){
db2.table_to_move.insert(cursor.next());
}
阅读(1670) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~