我有两个Oracle模式A&乙
我可以在模式A中创建一个触发器来监听模式B上的创建表吗? 如果是,我需要做哪些补助?
答案 0 :(得分: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
声明......