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
);
マテリアライズド ビューを作成しようとすると、次のエラーが発生します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.
「FROM 句」内のオブジェクトがどのように相互に依存しているかがわかりません。
これを機能させるにはどうすればよいですか?現在、考えられる唯一の回避策test3
は、通常のテーブルに置き換えて、データを手動で削除および更新することです。このアプローチは機能しますが、ちょっとしたハックのように思えます。
別の方法として (そしておそらく望ましいことですが)、2 つのテーブルを持つことができ、それらをマテリアライズド ビューに結合できる例を見てみたいと思います。ここでは、ベース テーブルの 1 つが一括更新されます (マテリアライズド ビューに反映する必要はありません)。 )しかし、他の更新はマテリアライズドビューに反映される必要があります(つまり、「半分」fast refresh on commit
と半分のようなものですcomplete refresh on demand
)。を使用してみましrefresh force
たが、使用するEXECUTE DBMS_MVIEW.EXPLAIN_MVIEW()
と、コミット時にフラッシュが更新されているという証拠が見つかりませんでした。union all
sでもこれをやりたいと思います。