所有类型的快速刷新物化视图都必须满足的条件:
1.物化视图不能包含对不重复表达式的引用,如sysdate和rownum;
2.物化视图不能包含对long和long raw数据类型的引用。但是从测试环境上看支持对raw类型的引用。
1.不能包括group by语句或聚集操作;
yang@rac1>create materialized view mv_yang_err refresh fast on commit with rowid
2 as select id ,count(1) from yang_a group by id;
as select id ,count(1) from yang_a group by id
*
第 2 行出现错误:
ora-32401: "yang"."yang_a" 上的实体化视图日志没有新值
yang@rac1>create materialized view mv_yang_pk refresh fast on commit
2 as select id ,count(1) from yang_pk group by id;
as select id ,count(1) from yang_pk group by id
*
error at line 2:
ora-32401: materialized view log on "yang"."yang_pk" does not have new values
2.如果在where语句中包含外连接,那么唯一约束必须存在于连接中内表的连接列上:
yang@rac1>drop materialized view mv_fact_err;
materialized view dropped.
yang@rac1>alter table fact drop constraint fact_fk_aid;
table altered.
yang@rac1>alter table yang_a drop primary key ;
yang@rac1>create materialized view mv_fact_err refresh fast on commit as
2 select f.rowid frid,a.rowid arid,b.rowid brid,f.id,
3 a.name aname,b.name bname ,val
4 from fact f ,yang_a a,yang_b b
5 where f.aid=a.id(+)
6 and f.bid=b.id;
materialized view created.
物化视图可以被建立,看来条件不成立。
3.如果不包含外连接,那么where语句没有限制,如果包含外连接,那么where语句中只能使用and连接,并且只能使用“=”操作:
6 and f.bid != b.id;
此条件不成立。
4.from语句列表中所有表的rowid必须出现在select语句的列表中:
2 select b.rowid brid,f.id,
from fact f ,yang_a a,yang_b b
*
error at line 4:
ora-12052: cannot fast refresh materialized view yang.mv_fact_err
5.from语句列表中的所有表必须建立基于rowid类型的物化视图日志。
ora-12052: cannot fast refresh materialized view yang.mv_fact_err