1、on demand:使用DBMS_MVIEW包中的存儲過程啟用手工刷新(默認設置)
refresh [fast|complete|force] 視圖刷新的方式:
complete:全部刷新。相當於重新執行一次創建視圖的查詢語句。
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;
/
dbms_mview.refresh(TAB=>'MV_TEST',
METHOD=>'COMPLETE',
PARALLELISM=>8);
end;
/
增量刷新就不需要使用什么並行了,通常情況下,是沒有那個必要的。
begin
dbms_mview.refresh(TAB=>'MV_TEST',
METHOD=>'FAST',
PARALLELISM=>1);
end;
/
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;
