当前位置:网站首页>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;
边栏推荐
- Baidu map JS browsing terminal
- Tutorial for beginners of small programs day01
- CentOS MySQL installation details
- Generate directory in markdown
- Deep understanding of continuation principle
- Why must redis exist in distributed systems?
- Express の Hello World
- What kind of experience is it to develop a "grandson" who will call himself "Grandpa"?
- Golang magic code
- 【新书推荐】MongoDB Performance Tuning
猜你喜欢

Distributed things

4. use ibinder interface flexibly for short-range communication

5. Messager framework and imessager interface

What kind of experience is it to develop a "grandson" who will call himself "Grandpa"?

8.8 heap insertion and deletion

Flutter 0001, environment configuration

Express - static resource request

JVM notes (III): analysis of JVM object creation and memory allocation mechanism

Talk about how the kotlin collaboration process establishes structured concurrency

Applet learning path 2 - event binding
随机推荐
9.JNI_ Necessary optimization design
Deeply understand the working principle of kotlin collaboration suspend (beginners can also understand it)
Reading notes of "Introduction to deep learning: pytoch"
Deep Learning with Pytorch-Train A Classifier
Niuke walks on the tree (ingenious application of parallel search)
Metasploit practice - SSH brute force cracking process
Dart asynchronous task
Application of hongruan face recognition
Coredata acquisition in swift sorting, ascending, descending
Wechat development tool (applet)
Why won't gold depreciate???
float
JVM family
Distributed things
Express の post request
About the smart platform solution for business hall Terminal Desktop System
Esp32 things (x): other functions
12. problem set: process, thread and JNI architecture
Using appbarlayout to realize secondary ceiling function
Duplicate entry '2' for key 'primary appears in JPA‘