从侦听事件的另一用户的用户在Oracle中创建触发器(Create trigger on Oracl

2019-10-20 13:50发布

我有两个甲骨文模式A和B.

我可以创建模式的一个触发器,它会听上创建架构B表? 如果是的话,授予我需要做什么?

Answer 1:

是的你可以。 该用户需要有CREATE ANY TRIGGER

作为DBA:

CREATE USER a IDENTIFIED BY a;
GRANT CREATE SESSION, CREATE ANY TRIGGER TO a;

CREATE USER b IDENTIFIED BY b;
GRANT CREATE SESSION TO b;

作为一个:

CREATE OR REPLACE TRIGGER a.create_trigger
  BEFORE CREATE ON b.SCHEMA
BEGIN
  raise_application_error(num => -20000,  msg=> 'create_trigger vetoes');
END;
/

由于B:

CREATE TABLE t(i INT);
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-20000: create_trigger vetoes
ORA-06512: at line 2

你必须微调此触发器,将火不仅为CREATE TABLE而是对所有CREATE语句...



文章来源: Create trigger on Oracle from a user that listens to events for another user