禁止DDL執行的trigger

myownstars發表於2011-10-21

禁止DDL執行的trigger
CREATE OR REPLACE TRIGGER disable_ddl
BEFORE DDL ON  SCHEMA
BEGIN
       IF ora_sysevent <> 'TRUNCATE'
         and  not (ora_sysevent = 'ALTER' AND ora_dict_obj_type = 'PROCEDURE')
         and not (ora_sysevent = 'CREATE' AND ora_dict_obj_type = 'PROCEDURE')
         and  not (ora_sysevent = 'ALTER' AND ora_dict_obj_type = 'TRIGGER')
         and not (ora_sysevent = 'CREATE' AND ora_dict_obj_type = 'TRIGGER')
         and  not (ora_sysevent = 'ALTER' AND ora_dict_obj_type = 'VIEW')
         and not (ora_sysevent = 'CREATE' AND ora_dict_obj_type = 'VIEW')
         and  not (ora_sysevent = 'ALTER' AND ora_dict_obj_type = 'FUNCTION')
         and not (ora_sysevent = 'CREATE' AND ora_dict_obj_type = 'FUNCTION')
       THEN
          RAISE_APPLICATION_ERROR(-20110,'No DDL in any time, please contact DBA team If you turly need it.',TRUE);
       END IF;
END;

SQL> create table justin (id number(10));
 
create table justin (id number(10))
 
ORA-00604: error occurred at recursive SQL level 1
ORA-20110: No DDL in any time, please contact DBA team If you turly need it.
ORA-06512: at line 12

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15480802/viewspace-709459/,如需轉載,請註明出處,否則將追究法律責任。

相關文章