码迷,mamicode.com
首页 > 数据库 > 详细

【代码备份】ORACLE数据库表同步DBLINK

时间:2018-11-15 22:24:36      阅读:255      评论:0      收藏:0      [点我收藏+]

标签:height   oracle   protoc   val   存储过程   res   where   http   HERE   

技术分享图片
---创建目标数据库连接DBLINK
create database link testdblink
connect to xxx identified by "xxx"
using ‘(DESCRIPTION =(ADDRESS_LIST =(ADDRESS =(PROTOCOL = TCP)(HOST = xxx.xxx.x.x)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME = emis)))‘;


---创建存储过程

CREATE OR REPLACE PROCEDURE PROC_A IS
begin
merge into A@testdblink b
using A c
on (b.ID = c.ID)
when matched then
update set b.STATE = c.STATE where b.ID = c.ID
when not matched then
insert
(b.STATE,
b.ID)
values
(c.STATE,
c.ID);
commit;
end PROC_A;


--创建DBMS_JOBS定时器,定时执行存储过程
declare jobno number;
begin
dbms_job.submit(jobno,‘PROC_A;‘, sysdate, ‘sysdate+1/24/60‘);
commit;
end;
/

【代码备份】ORACLE数据库表同步DBLINK

标签:height   oracle   protoc   val   存储过程   res   where   http   HERE   

原文地址:https://www.cnblogs.com/haozhenjie819/p/9966062.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!