Professional Documents
Culture Documents
Audit feature provides auditing at three levels in Oracle 10R2 Standard Edition viz.
1. Statement Auditing
Information captured:
2. Privilege Auditing
Information captured:
Specify a system privilege to audit SQL statements that are authorized by the specified
system privilege.
Rather than specifying many individual system privileges, you can specify the roles
CONNECT, RESOURCE, and DBA.
Oracle Database also provides two shortcuts for specifying groups of system privileges
and statement options at once: ALL and ALL PRIVILEGES to audit system privileges.
4. Maintenance
AUD$ table holds all information when DB audit parameter is used, this
needs to be cleaned up regularly otherwise it may grow big in size. In
10g there is no maintenance plan provided by Oracle so we can implement
a batch job to run DELETE statement for records that have creation date
older than 3 months (retention period suggested by client).
Please find below steps to implement cleanup of AUD$ table in 11g onwards databases:
BEGIN
DBMS_AUDIT_MGMT.INIT_CLEANUP(
AUDIT_TRAIL_TYPE => DBMS_AUDIT_MGMT.AUDIT_TRAIL_ALL,
DEFAULT_CLEANUP_INTERVAL => 24 /* in hours */);
END;
/
2. Create Stored Procedure to set timestamp for cleanup and run purge
AS
BEGIN
SYS.DBMS_AUDIT_MGMT.set_last_archive_timestamp (
audit_trail_type => SYS.DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD,
last_archive_time => systimestamp – 1 /* number of days */
);
SYS.DBMS_AUDIT_MGMT.CLEAN_AUDIT_TRAIL (
audit_trail_type => SYS.DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD,
use_last_arch_timestamp => TRUE);
END;
/
3. Schedule purge job using DBMS SCHEDULER
BEGIN
SYS.DBMS_SCHEDULER.CREATE_JOB (
job_name => 'PURGE_ALL_AUDIT_TRAILS',
job_type => 'PLSQL_BLOCK',
job_class => 'DEFAULT_JOB_CLASS',
job_action => 'BEGIN SP_PURGE_AUDIT_TRAILS(); END;',
start_date => systimestamp,
end_date => null,
repeat_interval=> 'FREQ=HOURLY;INTERVAL=1',
comments => 'This job cleans out audit trails, using DBMS_AUDIT_MGMT'
);
END;
/
4. Verify clean-up
set ORACLE_HOME=E:\Oracle\product\10.2.0\db_1
set PATH=%ORACLE_HOME%\bin:%PATH%
set LD_LIBRARY_PATH=%ORACLE_HOME%\lib
set ORACLE_SID=VIFSL
sqlplus sys/oracle as sysdba @C:\ncs\auditcleanup\delete_stmt.sql
SQL SCRIPT
Schedule this batch script in task manager to run on regular basis. If OS is linux then schedule in crontab.