查看触发器的源代码


创建触发器
SYS @ prod > CREATE OR REPLACE TRIGGER drop_trigger
       BEFORE DROP ON hr.SCHEMA
       BEGIN
          RAISE_APPLICATION_ERROR (
             num => -20000,
             msg => 'Cannot drop object');
       END;

Trigger created.


根据创建触发器时指定的 TABLE_OWNER 为 HR,查找刚才创建的触发器
SYS @ prod > select owner,trigger_name,table_owner from dba_triggers where table_owner='HR';

OWNER TRIGGER_NAME         TABLE_OWNE
----- -------------------- ----------
HR    SECURE_EMPLOYEES     HR
HR    UPDATE_JOB_HISTORY   HR
SYS   DROP_TRIGGER         HR


根据 触发器名称、触发器所属用户查找该触发器的编写代码
SYS @ prod >  select dbms_metadata.get_ddl('TRIGGER','DROP_TRIGGER','SYS') from dual;

DBMS_METADATA.GET_DDL('TRIGGER','DROP_TRIGGER','SYS')
--------------------------------------------------------------------------------

  CREATE OR REPLACE TRIGGER "SYS"."DROP_TRIGGER"
   BEFORE DROP ON hr.SCHEMA

posted @ 2015-07-30 21:25  Oracle-fans  阅读(793)  评论(0编辑  收藏  举报