当前位置:网站首页>oracle跨数据库复制数据表-dblink
oracle跨数据库复制数据表-dblink
2022-06-30 09:32:00 【珍-】
-一、最近有一个这样的需求,之前的数据库(部署在4.9),进程不足,需要迁移 到新的数据库(2.77),包括表结构和表数据,一个一个复制着实比较麻烦,在网上百度了下,才知道有dblink这种实现方式,下面就介绍下两种实现方式
实现方式有两种,
第一种是通过手动复制实现。
打开原有数据库,找到需要复制的表->右击->编辑->
点击VIEW SQL->复制insert语句到新的数据库执行,
再复制注释到新的数据库执行,这种方式需要打开需要复制的每张表,
多次复制,比较麻烦,而且当数据比较多的时候,执行insert语句直接卡死。
第二种方式:通过dblink实现
dblink是单向的,假设需要从A数据库复制到B数据库,
就要在A数据库中创建dblink,连接到B数据库,
然后通过A中的dblink来访问B中的数据
dblink实现
在A数据库当前表空间创建dblink,代码:
create public database link "LINK_NAME"
connect to "username" identified by "password"
using '(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = ip)(PORT = 1521))
(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = orcl)))';
其中:LINK_NAME 是dblink的名字,username 是B(新数据库)的账号,
password 是B(新数据库)的密码,ip是指数据库的ip地址,public可以去掉,不加public 只能当前这个用户看到,加了public可以被所有用户看到
执行这段代码,dblink就成功创建好了,可以通过oracle界面查看(A数据库)
在A数据库中实现访问B数据库中IPC_TEST表
select * from IPC_TEST @LINK_NAME
将A数据库中的test表数据复制到B数据库,也命名为test,前提是B数据库中已经有了test这张表
insert into [email protected]_NAME select * from test
B数据库中没有这张表直接通过A数据库创建表时,会提示不能对远程数据库进行DDL操作,这时候还需要写成存储过程才能实现远程建表并复制表数据
删除dblink
drop public database link LINK_NAME;
边栏推荐
- Why must redis exist in distributed systems?
- JVM family
- MySQL-- Entity Framework Code First(EF Code First)
- Pipe pipe --namedpipe and anonymouspipe
- Pass anonymous function to simplification principle
- Design of mfc+mysql document data management system based on VS2010
- Golang magic code
- Wechat development tool (applet)
- Talking about the difference between kotlin collaboration and thread
- Express の post request
猜你喜欢

目标检测yolov5开源项目调试
![[shutter] solve failed assertion: line 5142 POS 12: '_ debugLocked‘: is not true.](/img/77/eb66ec83b34c251e732d495fbaa951.jpg)
[shutter] solve failed assertion: line 5142 POS 12: '_ debugLocked‘: is not true.

Find the number that appears only once in the array

Distributed things

8.8 heap insertion and deletion

12. problem set: process, thread and JNI architecture

Talk about the job experience of kotlin cooperation process

Abstract factory pattern

Talk about how the kotlin process started?

Electron, which can wrap web page programs into desktop applications
随机推荐
Coredata acquisition in swift sorting, ascending, descending
桂林 穩健醫療收購桂林乳膠100%股權 填補乳膠產品線空白
Use of Baidu face recognition API
Design of mfc+mysql document data management system based on VS2010
UltraEdit delete empty line method
Startup of MySQL green edition in Windows system
ReturnJson,让返回数据多一些自定义数据或类名
Distributed ID
Niuke walks on the tree (ingenious application of parallel search)
List set export excel table
Express file download
About MySQL Boolean and tinyint (1)
Challenge transform() 2D
DataTableToModelList实体类
Solution to the sixth training competition of 2020 provincial competition
[wechat applet] realize applet pull-down refresh and pull-up loading
Explanation on the use of password profiteering cracking tool Hydra
Talk about writing
Pytorch for former Torch users - Tensors
Deep Learning with Pytorch- A 60 Minute Blitz