首页 > Linux操作系统 > Linux操作系统 > 记录一个防止DDL的脚本-ZT
create or replace trigger ddl_deny
before create or alter or drop or truncate on database
declare
l_errmsg varchar2(100):= 'You are not allowed to take this operation';
begin
if ora_sysevent = 'CREATE' then
raise_application_error(-20001, ora_dict_obj_owner || '.' || ora_dict_obj_name || ' ' || l_errmsg);
elsif ora_sysevent = 'ALTER' then
raise_application_error(-20001, ora_dict_obj_owner || '.' || ora_dict_obj_name || ' ' || l_errmsg);
elsif ora_sysevent = 'DROP' then
raise_application_error(-20001, ora_dict_obj_owner || '.' || ora_dict_obj_name || ' ' || l_errmsg);
elsif ora_sysevent = 'TRUNCATE' then
raise_application_error(-20001, ora_dict_obj_owner || '.' || ora_dict_obj_name || ' ' || l_errmsg);
end if;
exception
when no_data_found then
null;
end;
/
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/293106/viewspace-580529/ ,如需转载,请注明出处,否则将追究法律责任。