Oracle 数据库跨库同步表有很多种方式可以实现, 比如触发器, Materialized View(MV), Stream, Goldengate 等Materialized View(物化视图)是包括一个查询结果的数据库对像, 它是远程数据的的本地副本, 或者用来生成基于数据表求和的汇总表. 物化视图存储基于远程表的数据, 也可以称为快照. 这个基本上就说出了物化视图的本质, 它是一组查询的结果, 这样势必为将来再次需要这组数据时大大提高查询性能.下面就介绍使用 Materialized View + Job 的方式来双向同步表,具体步骤如下:1. 在源数据库 A 和目标数据库 B 上分别建立 table create table test
(
id varchar2(10) not null primary key,
name varchar2(20),
status varchar2(1),
updatedate date
) 2. 在数据库上分别建立 dblinkcreate database link dblink_to_B
connect to "userid" identified by "password"
using "(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = "ipaddress")(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = "SID")
)
)";
create database link dblink_to_A
connect to "userid" identified by "password"
using "(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = "ipaddress")(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = "SID")
)
)"; 3. 在源数据库 A 上建立 Materialized View 以及 Materialized view logcreate materialized view log on test with rowid
create materialized view mv_test refresh fast on demand with rowid
as select * from <A href="mailto:test@dblink_to_B">test@dblink_to_B</A>
SQL Server 2005数据库读写分离Oracle如何复制表的sql语句相关资讯 Oracle基础教程 Oracle物化视图 物化视图 Oracle数据库同步
- Oracle物化视图的用法与总结 (07月16日)
- Oracle物化视图失效的几种情况及测 (01/04/2015 11:41:16)
- Oracle中Job定期执行存储过程刷新 (10/18/2014 07:17:20)
| - OGG实现两台Oracle数据库的同步 (01/17/2015 15:24:47)
- 物化视图刷新时报0RA-01400的错误 (10/30/2014 19:18:50)
- 物化视图定义不当引发Oracle性能问 (02/22/2014 20:40:09)
|
本文评论 查看全部评论 (0)