Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Who Dropped Table?
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
![]() |
![]() |