mongodb - 集合重命名
2016-03-12 14:30
399 查看
#创建新的集合yb > for(i=0;i<10;i++){db.yb.insert({'i':i})} WriteResult({ "nInserted" : 1 }) > show collections yb #重命名集合为yb2 > db.yb.renameCollection('yb2'); { "ok" : 1 } > show collections yb2 >
跨数据库重名集合
> use test switched to db test > show collections yb1 > use test2 switched to db test2 > show collections > db.runCommand({renameCollection:"test.yb1",to:"test2.yb",dropTarget:true}); { "ok" : 0, "errmsg" : "renameCollection may only be run against the admin database.", "code" : 13 } > show collections > use admin switched to db admin > db.runCommand({renameCollection:"test.yb1",to:"test2.yb",dropTarget:true}); { "ok" : 1 } >
相关文章推荐
- mongodb 监控命令mongostat
- CentOS 手工编译、手动编译安装 MongoDB
- MongoDB查询并更新一粟
- mongodb
- spring整合springMVC、mybatis、hibernate、mongodb框架
- MongoDB Java 学习笔记
- mongodb 备份和还原
- MongoDB的c++封装api
- spring-date-mongodb-1.0.0.M2 添加用户密码验证
- MongoDB创建索引(不锁库方法)
- Windows7下安装MongoDB
- 部署MongoDB Replica Set同时给数据库设置用户名密码
- 以windows Service的方式启动MongoDB
- python+mongodb==pymongo的源码安装
- Mongodb - TTL(time to live)特性
- MongoDB驱动之Linq操作
- 配置MongoDB的Windows服务
- MongoDB空间分配
- MongoDB操作:insert()
- MongoDB空间分配