透過觸發器禁止模式物件的DDL操作

llnnmc發表於2017-05-11

create or replace trigger rmes.tri_ddl_deny

  before create or alter or drop or truncate on database

-- 禁用對RMES模式的DDL操作

 

declare

  my_errnum number := -20001;

  my_errmsg varchar2(100) := 'You have no permission to this operation.';

begin

  if ora_dict_obj_owner = 'RMES' then

    if ora_sysevent in ('CREATE', 'ALTER', 'DROP', 'TRUNCATE') then

      raise_application_error(my_errnum,

                              ora_dict_obj_owner || '.' ||

                              ora_dict_obj_name || ' ' || my_errmsg);

    end if;

  end if;

exception

  when no_data_found then

    null;

end;

/

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

相關文章