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,

  1. 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 
  1. at later point in time, reason, master table master_tab gets truncated
  2. 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 
  1. what kind of decisions oracle take internally fetch data materialized views?
  2. would oracle still retrieve correct data materialized view if master table empty?
  3. 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:

  1. 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

  1. the integrity level query_resrite_integrityis used see if allowed use query rewrite or not. default enforced, , can trusted or stale_tolerated. in case, if trusted or stale_tolerated, query still rewritten , data retrieved mv

  2. i believe yes, given 2


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -