当前位置:网站首页>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);})
边栏推荐
- cout.write的学习
- Changjiang storage launched its own storage brand "Zhiti", and the first SSD product was exposed
- Leetcode79 method 1: deep search
- 腾讯汤道生:开源是产业互联网时代新的生产方式和协作模式
- 天线的原理、分类及要求
- solidity的msg.value
- VSC writes go, expected 'package' appears, found 'EOF‘
- GIS数据漫谈(六)— 投影坐标系统
- Centos8 creates wordpress+mysql error reports according to the official website of docker
- Iptables firewall port rule configuration
猜你喜欢

Tcp/ip detailed diagram

频谱分析仪的性能参数

Composition and principle of vector network analyzer (vector network)

ADS仿真 之 交流仿真和S参数仿真示例

Application of Internet of things in smart city

USB type-C details

insight! Baidu pushed redis ceiling notes, which was originally understood by the database

Calibration of vector network analyzer (vector network)

Performance parameters of spectrum analyzer

电源适配器 全球定义
随机推荐
haproxy实现代理配置
低码在数字化转型中扮演什么角色?
About the difference between root and alias under localization
Implementation of solid transfer function (based on transfer)
Application of Internet of things in smart city
马斯克利用活猪展示全新脑机接口技术:可实时读取猪脑信息
VMware virtual machine networking settings (win10 comes with virtual machine installation win7)
Introduction to the principle of signal source
cout.write的学习
华为中兴在英国败诉,不交专利授权费将被禁售!
数字化洪流 :企业转型中的资源重组与战略冲突
What role does low code play in the digital transformation?
VSC上写Go出现expected ‘package‘, found ‘EOF‘
The US ban on Huawei began to affect European chip manufacturers
"Cloud strategy" will become an important pillar of enterprise digital transformation
Internet intelligence, how to define the next generation network transformation
Principle, classification and requirements of antenna
Apple supplier JDI plans to sell Baishan LCD plant and equipment for us $675million
互联智能,如何定义下一代网络变革
Msg.value of solidity