使用物化视图的方式进行数据同步

-- 在source db 上创建物化视图

SQL> conn scott/oracle


SQL> create table test (id int primary key);


Table created.



SQL> create materialized view log on test;


Materialized view log created.


-- 在目标端创建db link


SQL> conn scott/oracle

Connected.

SQL> create database link PREMIUMI connect to scott identified by oracle using 'source_db';


Database link created.


SQL> select * from test@PREMIUMI;


no rows selected


create materialized view test refresh fast start with sysdate next sysdate+1/(1440*60) with primary key as select * from test@PREMIUMI;



SQL> create materialized view test refresh fast start with sysdate next sysdate+1/(1440*60) with primary key as select * from test@PREMIUMI;


Materialized view created.




--测试

source db


SQL> insert into test values (1);


1 row created.


SQL> commit;


Commit complete.


-- target db

SQL> select * from test;


       ID

----------

        1


你可能感兴趣的:(高级复制,物化视图)