Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Who Dropped Table?

Who Dropped Table?

From: Post, Ethan <Ethan.Post_at_ps.net>
Date: Thu, 18 Apr 2002 11:43:41 -0800
Message-ID: <F001.004488FF.20020418114341@fatcity.com>


Goofing around with a procedure to log DROP TABLE and CREATE TABLE to the alert log. Thought I would share it with you. This is easier to implement than auditing in my opinion. I use this is very stable environments, my alert log monitor will send me an email when the event is triggered. I have been using the sys.dbms_system.ksdwrt more and more lately and let me log monitor parse the results. I also log some server error events to the log, I will include that below. This helps me identify specific sessions having problems in the database. Enjoy!

create or replace trigger tk$ddl_event after DROP or CREATE

   on database
declare

   mysession v$session%rowtype;
begin

   if ora_dict_obj_type = 'TABLE' then

      select * into mysession from v$session where sid = (select distinct sid from v$mystat);

      sys.dbms_system.ksdwrt(2,'DDL-' || ora_sysevent || ' ' || ora_dict_obj_type ||

         ' ' || ora_dict_obj_owner || '.' || ora_dict_obj_name || ' ' ||
         'SESSION ' || mysession.sid || ',' || mysession.serial# || ' USER '
||
         mysession.username || ',' || mysession.osuser || ' PROGRAM ' ||
mysession.program ||
         ',' || mysession.machine || ' OBJECT ' || ora_dict_obj_owner || '.'
|| ora_dict_obj_name);

   end if;
exception

   when others then

      dbms_output.put_line(dbms_utility.format_error_stack); end;

create or replace trigger tk$servererror after servererror

   on database
declare

   mysession v$session%rowtype;
begin

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Thu Apr 18 2002 - 14:43:41 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US