首页 » ORACLE » ORA-04089: cannot create triggers on objects owned by SYS

ORA-04089: cannot create triggers on objects owned by SYS

   今天做实验,忘记切换用户,在sys下建立触发器时发现了ORA-04089,不能建立trigger在sys的对象上

SQL> conn / as sysdba
Connected.
SQL> create table test_tr(id number,name varchar2(10));

Table created.

SQL> create or replace trigger tri_test_tr
2  before insert
3  on test_tr
4  for each row
5  begin
6  if :new.id >1000 then
7  :new.id :=-1;
8  end if;
9  end;
10  /
create or replace trigger tri_test_tr
*
ERROR at line 1:
ORA-04089: cannot create triggers on objects owned by SYS

SQL> create table anbob.test_tr1 as select * from test_tr;

Table created.

SQL> l
1  create or replace trigger tri_test_tr1
2      before insert
3      on anbob.test_tr1
4      for each row
5      begin
6      if :new.id >1000 then
7      :new.id :=-1
8  ;
9      end if;
10*    end;
SQL> run
1  create or replace trigger tri_test_tr1
2      before insert
3      on anbob.test_tr1
4      for each row
5      begin
6      if :new.id >1000 then
7      :new.id :=-1
8  ;
9      end if;
10*    end;

Trigger created.

总结:

不可以在sys的对象上创建trigger,业务上的对象一定要保存其它的用户下,oracle是出于什么原因,在网上也没找到,绝的sys就像os 里的root,它用最高的权限。我觉得应该出于安全的角度。

04089, 00000, “cannot create triggers on objects owned by SYS”
// *Cause:  An attempt was made to create a trigger on an object owned by SYS.
// *Action: Do not create triggers on objects owned by SYS.

打赏

目前这篇文章有1条评论(Rss)评论关闭。

  1. Mervin Cerrano | #1
    2011-12-21 at 07:12

    Thanks for taking the time to talk about this, I feel strongly about it and enjoy learning much more on this subject. If achievable, as you gain experience, would you mind updating your weblog with more details? Its very useful for me.

上一篇:

下一篇: