用物化视图同步两边数据库

 
1.在从库a里建立dblink:
      CREATE PUBLIC DATABASE LINK "ORA8I"
     CONNECT TO bwisp
     IDENTIFIED BY sa
   USING '(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = 168.10.98.26) (PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = ora10g)))';
2.在主库b相应的表上建立日志视图(主表上有关键字)
CREATE MATERIALIZED VIEW LOG ON emp
3.在从库a中建立物化视图
create materialized view mt_emp
   refresh fast start with sysdate
   next sysdate+1/1440
   with primary key
as select * from emp@ora8i;

如果没有主键,可以用rowid
     create materialized view mt_emp
     refresh with rowid
    as select * froom emp@ora8i

你可能感兴趣的:(用物化视图同步两边数据库)