当前位置:网站首页>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);})
边栏推荐
- solidity转账函数的实现(基于transfer)
- 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!
- What role does low code play in the digital transformation?
- Leetcode79 method 1: deep search
- VSC writes go, expected 'package' appears, found 'EOF‘
- #夏日挑战赛#【FFH】JS自定义组件:DIY一个随点随用的键盘!(一)
- Msg.value of solidity
- GIS数据漫谈(六)— 投影坐标系统
- 7-day sales of video number exceed one million
- Mqtt over quic: the next generation Internet of things standard protocol injects new impetus into the message transmission scenario
猜你喜欢

信号源原理简介

示波器简介

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

【译】创意编码之噪音

低码在数字化转型中扮演什么角色?

微信公众号授权登录后报redirect_uri参数错误的问题

Performance parameters of spectrum analyzer

About the difference between root and alias under localization

Introduction to USB type-C PD fast charging
随机推荐
MediaTek has submitted an application to the US side, striving to supply goods to China after September 15
How does the video Number import the public domain traffic to the private domain
There is a special cryptology language called asn.1
MongoDB创建索引
示波器探头详解
Msg.value of solidity
Temporary URL
NDK 系列(5):JNI 从入门到实践,爆肝万字详解!
Summary of core knowledge points of Computer Composition Principles & key points of written interview [easy to understand]
ADS仿真 之 交流仿真和S参数仿真示例
网络RJ45接口详解
物联网在智慧城市的应用
欧美六国最快5日达 菜鸟推出快线产品 优化“端到端”履约服务
Go的walk库报错
Go's sleep
Detailed explanation of network RJ45 interface
Changjiang storage launched its own storage brand "Zhiti", and the first SSD product was exposed
Novice record: some small knowledge of mechanical keyboard
Mongodb create index
美国对华为禁令开始波及欧洲芯片厂商