本文转载处:http://itlab.idcquan.com/Oracle/induction/897648.html
在11.2之前,只要有其他的表或TYPE依赖了当前对象,这个对象就无法进行REPLACE了
这是11.2之前的情况,尝试执行CREATE OR REPLACE将会导致ORA-2303错误,在11.2中
Oracle
增加了FORCE功能,使得一个仅被TYPE所依赖的对象仍然可以执行REPLACE的操作:
有意思的是,FORCE语句的位置不对则不会生效,这时同样会报ORA-2303的错误,而并不会导致语句错误:
最后这个功能只对被TYPE所依赖的对象有效,一旦对象被表所依赖,则FORCE功能也不起作用:
Oracle的错误信息也变成了ORA-22866.其实这时可以预料的,因为一旦创建了表,就相当于进行了实体化的工作,如果依赖的类型发生了变化,将会影响表中已有的数据的读写。不过其实Oracle可以做到更进一步,就是如果表段没有创建或者表中没有插入数据的情况下,允许对依赖的对象进行修改。
在11.2之前,只要有其他的表或TYPE依赖了当前对象,这个对象就无法进行REPLACE了
点击(此处)折叠或打开
- SQL> create type t_num_tab is table of number;
-
- 2 /
-
- Type created.
-
- SQL> create type t_record is object (id number, n_tab t_num_tab);
-
- 2 /
-
- Type created.
-
- SQL> create or replace type t_num_tab is table of number(5);
-
- 2 /
-
- create or replace type t_num_tab is table of number(5);
-
- *
-
- ERROR at line 1:
-
- ORA-02303: cannot drop or replace a type with type or table dependents
点击(此处)折叠或打开
- SQL> create or replace type t_num_tab force is table of number(5);
- 2 /
-
- Type created.
-
- SQL> select * from v$version;
-
- BANNER
-
- --------------------------------------------------------------------------------
-
- Oracle Database11gEnterprise Edition Release 11.2.0.3.0 - 64bit Production
-
- PL/SQL Release 11.2.0.3.0 - Production
-
- CORE 11.2.0.3.0 Production
-
- TNS for Solaris: Version 11.2.0.3.0 - Production
-
- NLSRTL Version 11.2.0.3.0 - Production
点击(此处)折叠或打开
- SQL> create or replace force type t_num_tab is table of number(5);
-
- create or replace force type t_num_tab is table of number(5)
-
- *
-
- ERROR at line 1:
-
- ORA-02303: cannot drop or replace a type with type or table dependents
-
- SQL> create or replace type t_num_tab is table of number(5) force;
-
- 2 /
-
- create or replace type t_num_tab is table of number(5) force;
-
- *
-
- ERROR at line 1:
-
- ORA-02303: cannot drop or replace a type with type or table dependents
点击(此处)折叠或打开
- SQL> create table t_type_tab (id number, c_tab t_num_tab)
-
- 2 nested table c_tab storetbas c_tab_tab;
-
- Table created.
-
- SQL> create or replace type t_num_tab force is table of number(6);
-
- 2 /
-
- create or replace type t_num_tab force is table of number(6);
-
- *
-
- ERROR at line 1:
-
- ORA-22866: cannot replace a type with table dependents
Oracle的错误信息也变成了ORA-22866.其实这时可以预料的,因为一旦创建了表,就相当于进行了实体化的工作,如果依赖的类型发生了变化,将会影响表中已有的数据的读写。不过其实Oracle可以做到更进一步,就是如果表段没有创建或者表中没有插入数据的情况下,允许对依赖的对象进行修改。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30260000/viewspace-1819690/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/30260000/viewspace-1819690/