Oracle物化视图应用笔记
在两个数据库中实现数据增量同步
Oracle数据库IP:192.168.0.1(源库)、192.168.0.2(目标库)
1、在源库创建测试表TEST
- create table TEST
- (
- ID NUMBER not null,
- NAME VARCHAR2(200)
- );
create table TEST ( ID NUMBER not null, NAME VARCHAR2(200) );
2、插入一条数据
- INSERT INTO TEST(ID,NAME) VALUES (1,'1111');
- commit;
INSERT INTO TEST(ID,NAME) VALUES (1,'1111'); commit;
3、在源库创建物化视图日志表
- create materialized view log on TEST with rowid;
create materialized view log on TEST with rowid;
4、在目标库创建一个DBLink链接
- create database link DBLINK_TEST
- connect TO username identified by "123456"
- using '(DESCRIPTION =
- (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.1)(PORT = 1521))
- (CONNECT_DATA =
- (SERVER = DEDICATED)
- (SERVICE_NAME = orcl)
- )
- )' ;
create database link DBLINK_TEST connect TO username identified by "123456" using '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.1)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl) ) )' ;
5、在目标库创建针对源库中TEST表的物化视图表MV_TEST
- create materialized view MV_TEST
- Refresh fast
- on demand
- with rowid
- as SELECT * from TEST@DBLINK_TEST;
create materialized view MV_TEST Refresh fast on demand with rowid as SELECT * from TEST@DBLINK_TEST;
该表创建的同时,就会把源表中的数据同步过来;
6、手工执行同步
- call dbms_mview.refresh('MV_TEST');
相关推荐
风之羽翼 2019-11-13
xiaoxiangyu 2019-01-18
不懂 2019-04-28
cream 2018-02-28
爪哇Fighter 2017-08-12
oraclewindows 2016-12-21
xuanzi 2016-11-15
代码小弟 2016-07-16
89241244 2015-04-29
杨校 2015-01-04
Andrea0 2014-10-30
myinfinity 2014-10-18
红尘浪子 2014-02-22
runing 2013-11-25
Java学习 2013-11-17
85407217 2013-09-13
CJforever 2013-05-29
mcvsyy 2013-02-01