ogg中的MV问题

在使用 Oracle GoldenGate (OGG) 搭建生产环境时,遇到MV(Materialized Views)的问题。不支持带有ROWID的MV,且必须有主键。Truncates不被支持,需要使用DELETE FROM语句。解决方法包括将MV改为'FOR UPDATE'或在目标端重建MV和MV日志。测试表明,'FOR UPDATE'取决于业务需求,而带有ROWID的MV在OGG中也可以工作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最近在搭建生产环境的ogg时,遇到了MVIEW的问题
If your source system has materialized views, please pay attention to the following:

Limitations of support for materialized views (MVs)
● Materialized views created WITH ROWID are not supported.
● The materialized view log can be created WITH ROWID.
● The source table must have a primary key.
● Truncates of materialized views are not supported. You can use a DELETE FROM statement.
● Some Oracle GoldenGate initial-load methods do not support LOBs in a materialized view.
● For Replicat, the materialized view must be updateable.
● Full refreshes are supported for Oracle 10g and later.

A solution is to change the materialized views “FOR UPDATE” before replicating this table.

If you don’t do this REPLICAT will abend with this message:

2011-10-15 21:14:44  WARNING OGG-00869  OCI Error ORA-01732: data manipulation operation not legal on this view (status = 1732), SQL <INSERT INTO "SCHEMA_TAR"."MV_TABEL" ("ID","STR","DATUM") VALUES (:a0,:a1,:a2)>.
You can also enable DDL support and exclude the SNAPSHOTS (if they are in your mapping):

DDL INCLUDE all, EXCLUDE OBJTYPE 'SNAPSHOT'

http://mverzijl.wordpress.com/2011/10/15/materialized-views-with-goldengate/

我测试了rowid的MV,replicat会abend,我就把MV和MV_log都mapexclude了,然后在target端重新生成日志和MV(基础表是数据一致的),未见异常。
经过测试发现,加上for update也是可以的,但是要看业务需要了。

如果有要这样做的,还希望做下实验哦
SQL> select * from ttt;
        T1         T2
---------- ----------
        10          2
         4          2
SQL> alter table ttt modify (t1 number primary key);
SQL> create materialized view log on ttt with primary key;
SQL> create materialized view mv_ttt
build immediate
refresh fast on demand
with primary key
start with to_date('2014-12-24 23:28:50','YYYY-MM-DD HH24:MI:SS') NEXT SYSDATE + 10/1440
as 
select * from ttt;
可以,没有问题

尝试rowid的for update
SQL> create table forr as select * from ttt;
SQL> create materialized view log on forr with rowid;
SQL> create materialized view mv_forr
build immediate
refresh fast on demand
with rowid
start with to_date('2014-12-24 23:28:50','YYYY-MM-DD HH24:MI:SS') NEXT SYSDATE + 10/1440
for update
as 
select * from forr;
可以,没有问题
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值