『ORACLE』快速刷新物化視圖的方法(11g)


1、on demand:使用DBMS_MVIEW包中的存儲過程啟用手工刷新(默認設置)

refresh [fast|complete|force] 視圖刷新的方式:
complete:全部刷新。相當於重新執行一次創建視圖的查詢語句。
 
fast: 增量刷新.假設前一次刷新的時間為t1,那么使用fast模式刷新物化視圖時,只向視圖中添加t1到當前時間段內,主表變化過的數據.為了記錄這種變化,建立增量刷新物化視圖還需要一個物化視圖日志表。create materialized view log on (主表名)。(多張表時,此語句也生效,創建后,原來的表中會多出兩類視圖表:MLOG$_table_name和RUPD$_table_name)
 
force: 這是默認的數據刷新方式。當可以使用fast模式時,數據刷新將采用fast方式;否則使用complete方式。

 

2、on commit:在事務提交后刷新

使用情況

⑴僅用於快速刷新的物化視圖

⑵需要on commit refresh對象權限

⑶如果刷新失敗需要進行手工刷新

3、never:禁止物化視圖刷新

 

在計划時間進行刷新:使用start with 和next選項。從指定的時間開始,每隔一段時間(由next指定)就刷新一次;

比如說我們要全刷新一張mv_test物化視圖:
begin
     dbms_mview.refresh(TAB=>'MV_TEST',
                                       METHOD=>'COMPLETE',
                                       PARALLELISM=>8);
end;
/
增量刷新就不需要使用什么並行了,通常情況下,是沒有那個必要的。
begin
     dbms_mview.refresh(TAB=>'MV_TEST',
                                       METHOD=>'FAST',
                                       PARALLELISM=>1);
end;
/
 
或者,也可以這樣執行:
exec dbms_mview.refresh('MV_TEST','F');
 
 

create matherialized view emp_data

pctfree 5 

tablespace example

storage (initial 50K next 50K)

refresh fast next sysdate + 7

as select ...;

 

create matherialized view emp_data

pctfree 5 

tablespace example

using index storage (initial 25K next 25K)

refresh start with round(sysdate + 1) + 11/24

next next_day(trunc(sysdate),'MONDAY') + 15/24

as select * from sh.customers@remote union

select * from sh.customers@local;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM