티스토리 뷰

데이터베이스/오라클

Using Oracle DDL Triggers

쌀맛나는세상 2008. 1. 16. 15:33
Auditing database changes: Oracle provides DDL triggers to audit all schema changes and can report the exact change, when it was made, and by which user.

There are several ways to audit within Oracle and the following auditing tools are provided:
SQL audit command (for DML)
Auditing with object triggers (DML auditing)
Auditing with system-level triggers (DML and DDL)
Auditing with LogMiner (DML and DDL)
Fine-grained auditing (select auditing)

DDL triggers: Using the Data Definition Language (DDL) triggers, the Oracle DBA can automatically track all changes to the database, including changes to tables, indexes, and constraints. The data from this trigger is especially useful for change control for the Oracle DBA.

DDL triggers execute every time a DDL statement is executed, and adds new entries to your new table, as shown below:

connect sys/manager

create or replace trigger
DDLTrigger
AFTER DDL ON DATABASE
BEGIN
insert into
perfstat.stats$ddl_log
(
user_name,
ddl_date,
ddl_type,
object_type,
owner,
object_name
)
VALUES
(
ora_login_user,
sysdate,
ora_sysevent,
ora_dict_obj_type,
ora_dict_obj_owner,
ora_dict_obj_name
);

END;
/