Oracle物化视图错误:包含代码

Cli*_*ton 13 sql database oracle materialized-views

当我在Oracle 10g上运行以下代码时:

drop materialized view test4;
drop materialized view test3;
drop table test2;
drop table test1;

create table test1
(
  x1 varchar2(1000),
  constraint test1_pk primary key (x1)
);

create materialized view log on test1 with sequence;

create table test2
(
  x2 varchar2(1000),
  constraint test2_pk primary key (x2)
);

create materialized view log on test2 with sequence;

create materialized view test3
refresh complete on demand 
as
(
  select x1 from test1
  union all
  select null from dual where 0 = 1
);

alter table test3 add constraint test3_pk primary key (x1);

create materialized view log on test3 with sequence;

create materialized view test4
refresh fast on commit
as
(
  select t1.rowid as rid1, t2.rowid as rid2, t1.x1 u1, t2.x2
  from test3 t1, test2 t2
  where t1.x1 = t2.x2
);
Run Code Online (Sandbox Code Playgroud)

尝试创建物化视图时出现此错误test4:

SQL Error: ORA-12053: this is not a valid nested materialized view  
12053. 00000 -  "this is not a valid nested materialized view"  
*Cause:    The list of objects in the FROM clause of the definition of this  
           materialized view had some dependencies upon each other.  
*Action:   Refer to the documentation to see which types of nesting are valid.
Run Code Online (Sandbox Code Playgroud)

我不明白"FROM子句"中的任何对象如何相互依赖.

我如何让它工作?目前我能想到的唯一工作就是test3用普通表替换并手动删除和刷新数据.这种方法有效,但看起来有点像黑客.

或者(也许最好)我只想看一个可以有两个表的示例,并将它们连接到物化视图中,其中一个基表是批量更新的(并且不需要在物化视图中反映出来)但其他更新应反映在物化视图中(即它的"一半" fast refresh on commit和一半complete refresh on demand).我尝试使用refresh force,但在使用时,EXECUTE DBMS_MVIEW.EXPLAIN_MVIEW()我发现在提交可用时没有关于fash刷新的证据.我也想用union alls 做这个.

Flo*_*ita 2

引用自甲骨文

使用多层物化视图的限制

主物化视图和基于物化视图的物化视图都必须:

  • 成为主键物化视图
  • 驻留在兼容级别为 9.0.1 或更高版本的数据库中

注意:COMPATIBLE 初始化参数控制数据库的兼容性级别。

不过,我会为你尝试一个解决方案。我会回来的。

更新:抱歉我没有成功。你的限制太多了:)