Oracle實體視圖及樹形排序學習

 

materialized view

主要用於預先計算並保存表連接或聚集等耗時較多的操作的結果,這樣,在執行查詢時,就可以避免進行這些耗時的操作,而從快速的得到結果。

使用語法:

CREATE MATERIALIZED VIEW XX

  REFRESH [[fast | complete | force] 
         [on demand | commit] 
         [start with date] 
         [next date] 
         [with {primary key | rowid}] 
       ]

      [ENABLE | DISABLE] QUERY REWRITE

 遞歸查詢

   start with ...指定查詢的根行

   connect by prior... 父行和子行的關係(是以父行爲主)

  ORDER SIBLINGS BY ... 同級別排序

例:

create materialized view mv_auth_ycps
refresh force on demand 
start with to_date('2013-6-25 01:30:00','yyyy-mm-dd hh24:mi:ss')next sysdate+1
as
    select * 
    from acc_domain 
    where dtype='domain' 
    start with parent_id is null 
    connect by prior id = parent_id 
    ORDER SIBLINGS BY position;
 


參考資料:http://www.cnblogs.com/lizhe88/archive/2011/01/23/1942423.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章