DDL trigger to restrict user from creating objects in his schema

Today one of my friend asked me for a trigger by which he want to stop a particular user from misusing his privileges to create/drop any objects. Below is the trigger for the same.

  create or replace trigger ddl_trigger
  before DDL ON DATABASE
  declare
      l_sysevent varchar2(25);
  begin
      select ora_sysevent into l_sysevent from dual;

      if (l_sysevent in (‘CREATE’,’DROP’) AND ora_login_user in (‘TEMP’))
      then
      RAISE_APPLICATION_ERROR(-20998, ‘You do not have the privilege to create tables or other database objects. Please contact your manager if you need the privilege.’);  
      end if;
  end;
  /
  

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s