11g中物件細粒度管理一例

to_be_Dba發表於2013-03-15

 

11g中oracle提供了細粒度的物件管理。如:檢視所依賴的表若發生結構變化,在10g及以前版本中會導致檢視失效,而在11g中,若結構變化未影響檢視,則檢視仍然有效。

在11g中:

SQL> drop table t;

Table dropped

SQL> create table t as select * from emp;

Table created

SQL> create view v_t as select ename,deptno from t;

View created

SQL> select status from dba_objects where object_name='V_T';

STATUS
-------
VALID

SQL> alter table t add a varchar2(2);

Table altered

SQL> select status from dba_objects where object_name='V_T';

STATUS
-------
VALID

 

在10g中:

SQL> drop table t;

Table dropped

SQL> create table t as select * from emp;

Table created

SQL> create view v_t as select ename,deptno from t;

View created

SQL> select status from dba_objects where object_name='V_T';

STATUS
-------
VALID

SQL> alter table t add a varchar2(2);

Table altered

SQL> select status from dba_objects where object_name='V_T';

STATUS
-------
INVALID

 

若檢視是select * from table得到的,即使將檢視對應的表增加列,檢視也不會失效。

SQL> create view v_t2 as select * from t;

View created

SQL> select status from dba_objects where object_name='V_T';

STATUS
-------
VALID

SQL> alter table t add b varchar2(2);

Table altered

SQL> select status from dba_objects where object_name='V_T';

STATUS
-------
VALID

刪除一列,檢視依然無動於衷:

SQL> alter table t drop column a;

Table altered

SQL> select status from dba_objects where object_name='V_T';

STATUS
-------
VALID

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

相關文章