dbms_mview系列(五)_補

wisdomone1發表於2013-03-03

--修正method引數值為c,原為f;這下可以正常重新整理了
SQL> declare                                                                                                                                                                                                                                                
  2  out_err number;                                                                                                                
  3  begin                                                                                                                          
  4  dbms_mview.refresh_all_mviews(number_of_failures => out_err,method => 'c',refresh_after_errors => true,atomic_refresh => false);
  5  dbms_output.put_line(out_err);                                                                                                 
  6  end;                                                                                                                           
  7  /                                                                                                                              
                                                                                                                                    
0                                                                                                                                   
                                                                                                                                    
PL/SQL procedure successfully completed                                                                                             
                                                                                                                                    
SQL>  select * from mv_t;                                                                                                           
                                                                                                                                    
                                      A                                                                                             
---------------------------------------                                                                                             
                                      1  
                                     
適用於重新整理與master table相關的物化檢視                                     
REFRESH_DEPENDENT Procedures    

Syntax                                                                                                                                                                               
 DBMS_MVIEW.REFRESH_DEPENDENT (                          
   number_of_failures     OUT    BINARY_INTEGER,         
   { list                 IN     VARCHAR2,     --僅此引數與上述不同,為master table,而非mv          
   | tab                  IN     DBMS_UTILITY.UNCL_ARRAY,}
   method                 IN     VARCHAR2    := NULL,    
   rollback_seg           IN     VARCHAR2    := NULL,    
   refresh_after_errors   IN     BOOLEAN     := false,   
   atomic_refresh         IN     BOOLEAN     := true,    
   nested                 IN     BOOLEAN     := false);   

--插入資料到master table  
SQL> insert into t_mv select level from dual connect by level<=5;
                                                                
5 rows inserted                                                 
                                                                
SQL> commit;                                                    
                                                                
Commit complete   

SQL> select * from mv_t;                                                                                                                                                                      
                                                                                                                                                
                                      A                                                                                                         
---------------------------------------                                                                                                         
                                                                                                                                                
SQL>                                                                                                                                            
SQL> declare                                                                                                                                    
  2  out_err number;                                                                                                                            
  3  begin                                                                                                                                      
  4  dbms_mview.refresh_dependent(number_of_failures => out_err,list=>'mv_t',method => 'f',refresh_after_errors => true,atomic_refresh => false);
  5  dbms_output.put_line(out_err);                                                                                                             
  6  end;                                                                                                                                       
  7  /                                                                                                                                          
                                                                                                                                                
0                                                                                                                                               
                                                                                                                                                
PL/SQL procedure successfully completed                                                                                                         

--執行過程物化檢視依舊無值                                                                                                                                                
SQL> select * from mv_t;                                                                                                                        
                                                                                                                                                
                                      A                                                                                                         
---------------------------------------                                                                                                         
                                          
--list引數值為master table,而非mv,mv有值了                                          
SQL> declare                                                                                                                                                                                                                                                                                     
  2  out_err number;                                                                                                                            
  3  begin                                                                                                                                      
  4  dbms_mview.refresh_dependent(number_of_failures => out_err,list=>'t_mv',method => 'c',refresh_after_errors => true,atomic_refresh => false);
  5  dbms_output.put_line(out_err);                                                                                                             
  6  end;                                                                                                                                       
  7  /                                                                                                                                          
                                                                                                                                                
0                                                                                                                                               
                                                                                                                                                
PL/SQL procedure successfully completed                                                                                                         
                                                                                                                                                
SQL> select * from mv_t;                                                                                                                        
                                                                                                                                                
                                      A                                                                                                         
---------------------------------------                                                                                                         
                                      1                                                                                                         
                                      2                                                                                                         
                                      3                                                                                                         
                                      4                                                                                                         
                                      5       

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-755173/,如需轉載,請註明出處,否則將追究法律責任。

相關文章