利用OracleDBLink进行表同步

阅读更多

场景:从ORACLE A  同步表到ORACLE B

 

一、创建database link(B端)

create public database link dblink_name
 connect to A_user_name identified by A_user_password
 using '(DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = aa.bb.com)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl)
    )
  )';

 

二、创建snapshot(B端)

Create snapshot tb_name as select * from tb_name@dblink_name;
 

三、修改snapshot刷新时间(B端)

Alter snapshot tb_name refresh complete Start with sysdate next trunc(sysdate+1)+20/24;
--每天20点刷新

要手动刷新的话

dbms_refresh.refresh('"B"."TB_NAME"');

  查看最后一次刷新时间

SELECT NAME,LAST_REFRESH FROM ALL_SNAPSHOT_REFRESH_TIMES;
 

 

 

 

 

 

你可能感兴趣的:(Oracle)