ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Oracle11gr2新增CREATE OR REPLACE FORCE TYPE功能

Oracle11gr2新增CREATE OR REPLACE FORCE TYPE功能

原创 Linux操作系统 作者:yangtingkun 时间:2009-09-16 23:42:24 0 删除 编辑

在11.2中,Oracle增强了TYPE类型的依赖处理。

 

 

在以前的版本中,如果表或另一个对象依赖当前的对象,那么这个对象是无法CREATE OR REPLACE的,在11.2中,这个限制被放宽,当依赖当前对象的对象是对象时,允许使用CREATE OR REPLACE FORCE来重建对象;如果依赖当前对象的对象是表,则新增的CREATE OR REPLACE FORCE功能也是无效的。

SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE    11.2.0.1.0      Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production

SQL> create type t_id_tab is table of number(10);
  2  /

类型已创建。

SQL> create type t_id_tab_tab is table of t_id_tab;
  2  /

类型已创建。

SQL> create or replace type t_id_tab is table of number(20);
  2  /
create or replace type t_id_tab is table of number(20);
*
第 1 行出现错误:
ORA-02303:
无法使用类型或表的相关性来删除或取代一个类型


SQL> create or replace type t_id_tab force is table of number(20);
  2  /

类型已创建。

SQL> drop type t_id_tab;
drop type t_id_tab
*
第 1 行出现错误:
ORA-02303:
无法使用类型或表的相关性来删除或取代一个类型


SQL> drop type t_id_tab force;

类型已删除。

SQL> drop type t_id_tab_tab;

类型已删除。

可以看到使用FORCE功能可以避免当前的TYPE被其他对象所依赖后而无法重建或删除。不过这种依赖仅限于对象之间,如果依赖对象的是表,则FORCE功能不起作用:

SQL> create type t_type as object
  2  (id number,
  3  name varchar2(30));
  4  /

类型已创建。

SQL> create table t_type_tab of t_type;

表已创建。

SQL> create or replace type t_type as object
  2  (id number(5),
  3  name varchar2(30));
  4  /
create or replace type t_type as object
*
第 1 行出现错误:
ORA-02303:
无法使用类型或表的相关性来删除或取代一个类型


SQL> create or replace type t_type force as object
  2  (id number(5),
  3  name varchar2(30));
  4  /
create or replace type t_type force as object
*
第 1 行出现错误:
ORA-22866:
无法替换具有表相关性的类型

 

 

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4227/viewspace-614847/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
暂无介绍

注册时间:2007-12-29

  • 博文量
    1964
  • 访问量
    11076238