ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Oracle11gr2触发器依赖判断增强(一)

Oracle11gr2触发器依赖判断增强(一)

原创 Linux操作系统 作者:yangtingkun 时间:2009-10-09 23:44:22 0 删除 编辑

在11.1中,Oracle做到了对象的列级依赖,但是触发器并没有做到这一点。在11.2的新特性文档中提到了触发器也具备了列级依赖的能力。

Oracle11新特性——在线操作功能增强(三):http://yangtingkun.itpub.net/post/468/401641

 

 

在11.1.0.6上进行的测试:

SQL> create table t (id number);

表已创建。

SQL> create trigger t              
  2  before update of id on t
  3  for each row
  4  begin
  5  :new.id := 1;
  6  end;
  7  /

触发器已创建

SQL> col object_name format a30
SQL> select object_name, object_type, status
  2  from user_objects
  3  where object_name = 'T';

OBJECT_NAME                    OBJECT_TYPE                            STATUS
------------------------------ -------------------------------------- --------------
T                              TABLE                                  VALID
T                              TRIGGER                                VALID

SQL> alter table t add name varchar2(30);

表已更改。

SQL> select object_name, object_type, status
  2  from user_objects
  3  where object_name = 'T';

OBJECT_NAME                    OBJECT_TYPE                            STATUS
------------------------------ -------------------------------------- --------------
T                              TABLE                                  VALID
T                              TRIGGER                                INVALID

SQL> select * from v$version;

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

可以看到虽然触发器明确指明了依赖T的ID列,但是如果T表新增了其他列,仍然会导致触发器被置于INVALID状态。

而在11.2中:

SQL> create table t(id number);

表已创建。

SQL> create trigger t
  2  before update of id on t
  3  for each row
  4  begin
  5  :new.id := 1;
  6  end;
  7  /

触发器已创建

SQL> select object_name, object_type, status
  2  from user_objects
  3  where object_name = 'T';

OBJECT_NAME                    OBJECT_TYPE         STATUS
------------------------------ ------------------- -------
T                              TRIGGER             VALID
T                              TABLE               VALID

SQL> alter table t add name varchar2(30);

表已更改。

SQL> select object_name, object_type, status
  2  from user_objects
  3  where object_name = 'T';

OBJECT_NAME                    OBJECT_TYPE         STATUS
------------------------------ ------------------- -------
T                              TRIGGER             VALID
T                              TABLE               VALID

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

显然列级依赖的问题已经实现。

 

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

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

注册时间:2007-12-29

  • 博文量
    1964
  • 访问量
    11078716