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

來源:互聯網
上載者:User

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;

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.