Quando eseguo il seguente codice su Oracle 10g:Oracle vista materializzata errore: codice incluso
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
);
ottengo questo errore sul tentativo di creare la vista materializzata 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.
I don' t capire come uno qualsiasi degli oggetti nella "clausola FROM" dipende l'uno dall'altro.
Come posso farlo funzionare? Attualmente l'unico lavoro che posso immaginare è quello di sostituire test3
con una tabella ordinaria e cancellare e aggiornare manualmente i dati. Questo approccio funziona, ma sembra un po 'un trucco.
In alternativa (e forse preferibilmente) vorrei solo vedere un esempio in cui possono avere due tabelle e unirle in una vista materializzata, in cui una delle tabelle di base viene aggiornata in blocco (e non è necessario che venga riflessa nella vista materializzata) ma gli altri aggiornamenti dovrebbero riflettersi nella vista materializzata (ovvero è una specie di "metà" fast refresh on commit
e metà complete refresh on demand
). Ho provato a utilizzare refresh force
, ma quando si utilizza EXECUTE DBMS_MVIEW.EXPLAIN_MVIEW()
non ho trovato alcuna prova di aggiornamento fash sul commit disponibile. Mi piacerebbe anche farlo con union all
s.
+1 meglio spiegato e ora ilustrated :) –
'test3' non ha molto senso:' seleziona null da duale dove 0 = 1' non restituirà mai una riga. – Allan
@ Allan: questo è un trucco per trasformarlo in un aggregato. Sentiti libero di rimuoverlo se interrompe l'errore. – Clinton