当前位置:网站首页>MongoDB数据库复制表
MongoDB数据库复制表
2022-07-28 17:04:00 【水月清辉】
利用foreach方法在shell里直接运行
1, 将一个实例的表复制到另一个实例的表(同一个数据库)
db.collection_name.find().forEach(function(d){db.getSiblingDB('new_database')['collection_name'].insert(d);})
collection_name:数据库表名
new_database:目标数据库
2, 在同一个主机上同一个db下复制一个表
db.复制源表名.find().forEach(function(x){db.目的表名.insert(x);})
例子:
db.test.find().forEach(function(x){db.test_bak.insert(x);})
边栏推荐
- Dormant for two years! Lingsheng technology's first aiot chip released: Samsung 11nm process, integrated NPU core!
- Application of Internet of things in smart city
- Introduction to USB type-C PD fast charging
- .net WCF wf4.5 state machine, bookmark and persistence
- Video number from 2-3 games per week to 3 games per day
- haproxy实现灰度发布
- There is a special cryptology language called asn.1
- Strong performance growth! Wentai technology's net profit in the first half of the year was 1.7 billion yuan, a sharp increase of 767.19% year-on-year!
- DC simulation example of ADS simulation
- .net swagger
猜你喜欢

MQTT over QUIC:下一代物联网标准协议为消息传输场景注入新动力

顿悟!百度强推的Redis天花板笔记,原来数据库是这样理解的

矢量网络分析仪(矢网)组成和原理简介

#夏日挑战赛#【FFH】JS自定义组件:DIY一个随点随用的键盘!(一)

七个步骤,深入解读数据含义

TCP/IP详细图解

Food safety | will the salt content of bread exceed the standard? A few tips to teach you to eat bread correctly!

Five key considerations for network security budget planning in 2023

频谱仪原理简介一

一文简述:SRv6基本原理
随机推荐
Modifier modifier modifier of solidity _;
Principle, classification and requirements of antenna
Go的walk库报错
Dormant for two years! Lingsheng technology's first aiot chip released: Samsung 11nm process, integrated NPU core!
体验5分钟开发微信小程序
The growth path of hardware engineers (0) -- Understanding components
.net WCF WF4.5 状态机、书签与持久化
中芯国际上半年净利13.86亿元,N+1工艺已进入客户产品验证阶段
MySQL operation Encyclopedia
2023年网络安全预算规划的五个关键考虑因素
矢量网络分析仪(矢网)组成和原理简介
互联智能,如何定义下一代网络变革
Detailed explanation of network RJ45 interface
Power adapter global definition
Performance parameters of spectrum analyzer
Tcp/ip detailed diagram
云容器与云原生
Five key considerations for network security budget planning in 2023
有一种密码学专用语言叫做ASN.1
solidity转账函数的实现(基于transfer)