【代码备份】ORACLE数据库表同步DBLINK
---创建目标数据库连接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;
/