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

oracle数据库实现不同数据库之间的表格数据定期同步

时间:2018-06-09 22:08:08      阅读:252      评论:0      收藏:0      [点我收藏+]

标签:host   dfa   toc   dea   rtt   定时任务   lld   select   repo   

1、创建数据库连接

CREATE PUBLIC DATABASE LINK DBLINK01 CONNECT TO app IDENTIFIED BY appapp2018 USING (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 134.103.65.206)(PORT = 1521))
    (CONNECT_DATA =
      (SERVICE_NAME = ORCL)
    )
  );

2、创建存储过程

create or replace procedure test as   
begin   
DELETE FROM KDFAULTORDER;
INSERT INTO KDFAULTORDER
select
BUSINESSDATAID ID,
TITLE REPORTTITLE,
MAINSN  FAULTNUMBER,
(select SPECIALTYNAME from CCATSUPT.PUB_SPECIALTY@kdogg where SPECIALTYID= BIGSPECIALTY)BIGTYPE,
(select SPECIALTYNAME from CCATSUPT.PUB_SPECIALTY@kdogg where SPECIALTYID= SPECIALTY)SMALLTYPE,
(select BUSINESSNAME from CCATSUPT.sys_business@kdogg where BUSINESSID= BUSINESS)REPORTTYPE,
SOURCEDEPT REPORTRESOURCE,
FIRSTRECEPTTIME  REPORTTIME,
REQREPAIRTIME ENDTIME,
(select objectname from ccatsupt.org_tree@kdogg where itemid= REPAIROPER )DEALPERSON,
HASTENNUM REPAIRNUM,
decode(PROCESSFLAG,DECLARATE,申告,BILLDEAL,工单处理中,HANGUP,挂起,VISIT,待回访) ORDERSTATUS,
ALARMSTATUS WARNSTATUS,
(select objectname from ccatsupt.org_tree@kdogg where itemid= regionid) AREANAME
from  CCATSUPT.Svr_Pub_Da_Mainqueue@kdogg
where
ARCHIVETYPE is null
and FIRSTRECEPTTIME < sysdate -15/1140
and REQREPAIRTIME > sysdate -15/1140;
end;

3、创建定时任务

declare  
job1 number;   
begin  
dbms_job.submit(job1,  
     what => test;,  
     next_date => sysdate,  
     interval => TRUNC(sysdate) + 1 + 1 / (24));
   commit;  
end;
// 查询当前数据库的所有定时任务
declare  
job1 number;   
begin  
dbms_job.submit(job1,  
     what => test;,  
     next_date => sysdate,  
     interval => TRUNC(sysdate) + 1 + 1 / (24));
   commit;  
end;  

// 运行某个定时任务
begin
dbms_job.run(29);
commit;
end;

 

oracle数据库实现不同数据库之间的表格数据定期同步

标签:host   dfa   toc   dea   rtt   定时任务   lld   select   repo   

原文地址:https://www.cnblogs.com/DreamSeekerming/p/9160872.html

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