oracle - Using a Materialized View with the Master table empty -
i executing tests concept of materialized views in oracle , wasn't able answer question, materialized view fetch rows when master table created becomes empty? have listed sequence of events below visualize have in mind,
- create valid materialized view based on huge master table
here's example
the master table
create table master_tab ( col1 varchar2(10), col2 varchar2(10), col3 varchar2(10), tr_val1 number, tr_val2 number, tr_val3 number )
the materialized view definition
create materialized view mview_test build immediate refresh complete on demand enable query rewrite select col1, col2 sum(tr_val1), sum(tr_val2) master_tab group col1, col2
- at later point in time, reason, master table master_tab gets truncated
- so, now, materialized view has data relevant query on master table master_tab
i wasn't conversant oracle behind scenes fetch correct data. now, happens when query gets executed application looking data master table? example, happens when application queries,
select col1, col2 sum(tr_val1), sum(tr_val2) master_tab group col1, col2
- what kind of decisions oracle take internally fetch data materialized views?
- would oracle still retrieve correct data materialized view if master table empty?
- if answer #2 yes, mean long materialized view isn't refreshed again, oracle still able fetch data queries looking data master?
thanks help
to try answer questions:
- to use query rewrite , have data fetched mv, following checked: a) query re-write enabled (session) b) query re-write enabled (mv) , c) re-write integrity check (i think need control)
the above in addition check on sql if can rewritten using mv (you can use dbms_mview.explain_rewrite
on sql advise if rewrite possible , mv used
the integrity level
query_resrite_integrity
is used see if allowed use query rewrite or not. defaultenforced
, , cantrusted
orstale_tolerated
. in case, iftrusted
orstale_tolerated
, query still rewritten , data retrieved mvi believe yes, given 2
Comments
Post a Comment