Manually Purging the Audit Trail
You can use the DBMS_AUDIT_MGMT.CLEAN_AUDIT_TRAIL procedure to manually purge the audit trail.
-
About Manually Purging the Audit Trail
You can manually purge the audit trail right away, without scheduling a purge job. -
Using DBMS_AUDIT_MGMT.CLEAN_AUDIT_TRAIL to Manually Purge the Audit Trail
After you complete preparatory steps, you can use theDBMS_AUDIT_MGMT.CLEAN_AUDIT_TRAILprocedure to manually purge the audit trail.
About Manually Purging the Audit Trail
You can manually purge the audit trail right away, without scheduling a purge job.
Similar to a purge job, you can purge audit trail records that were created before an archive timestamp date or all the records in the audit trail. Only the current audit directory is cleaned up when you run this procedure.
For upgraded databases that may still have audit trails from earlier releases, note the following about the DBMS_AUDIT_MGMT.CLEAN_AUDIT_TRAIL PL/SQL procedure:
-
On Microsoft Windows, because the
DBMS_AUDIT_MGMTpackage does not support cleanup of Windows Event Viewer, setting theAUDIT_TRAIL_TYPEproperty toDBMS_AUDIT_MGMT.AUDIT_TRAIL_OShas no effect. This is because operating system audit records on Windows are written to Windows Event Viewer. TheDBMS_AUDIT_MGMTpackage does not support this type of cleanup operation. -
On UNIX platforms, if you had set the
AUDIT_SYSLOG_LEVEL(deprecated) initialization parameter, then Oracle Database writes the operating system log files to syslog files. (Be aware that when you configure the use of syslog files, the messages are sent to the syslog daemon process. The syslog daemon process does not return an acknowledgment to Oracle Database indicating a committed write to the syslog files.) If you set theAUDIT_TRAIL_TYPEproperty toDBMS_AUDIT_MGMT.AUDIT_TRAIL_OS, then the procedure only removes.audfiles under audit directory (This directory is specified by theAUDIT_FILE_DEST(deprecated) initialization parameter).
Using DBMS_AUDIT_MGMT.CLEAN_AUDIT_TRAIL to Manually Purge the Audit Trail
After you complete preparatory steps, you can use the DBMS_AUDIT_MGMT.CLEAN_AUDIT_TRAIL procedure to manually purge the audit trail.
-
If you have set the
AUDIT_SYSLOG_LEVEL(deprecated) initialization parameter so that the audit trail will be written to operating system log files (syslog), then check for the following:-
Ensure that no one is currently writing to the audit trail files.
-
Ensure that the session ID that is associated with the audit trail files is not owned by the PMON process. Restart the database if this is true before purging the audit trail.
If either of these conditions is true, then the audit trail cannot be purged.
-
-
Perform the following scheduling tasks:
-
If necessary, tune the online and archive redo log sizes.
-
Plan a timestamp and archive strategy.
-
Optionally, set an archive timestamp for the audit records.
-
-
Connect to the root or to the PDB in which you created the purge job.
If you created the purge job in the root, then you must log into the root. If you created the purge job in a specific PDB, then log into that PDB.
-
Purge the audit trail records by running the
DBMS_AUDIT_MGMT.CLEAN_AUDIT_TRAILPL/SQL procedure.For example:
BEGIN DBMS_AUDIT_MGMT.CLEAN_AUDIT_TRAIL( AUDIT_TRAIL_TYPE => DBMS_AUDIT_MGMT.AUDIT_TRAIL_UNIFIED, USE_LAST_ARCH_TIMESTAMP => TRUE, CONTAINER => DBMS_AUDIT_MGMT.CONTAINER_CURRENT, DROP_PARTITION_ONLY => FALSE ); END; /
In this example:
-
AUDIT_TRAIL_TYPE: Specifies the audit trail type.DBMS_AUDIT_MGMT.AUDIT_TRAIL_UNIFIEDsets it for the unified audit trail.For upgraded databases that still have audit data from previous releases, use the following settings.Traditional auditing is desupported in Oracle AI Database 26ai. Oracle recommends that you use unified auditing.
-
DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD: Standard audit trail table,AUD$. (This setting does not apply to read-only databases.) -
DBMS_AUDIT_MGMT.AUDIT_TRAIL_FGA_STD: Fine-grained audit trail table,FGA_LOG$. (This setting does not apply to read-only databases.) -
DBMS_AUDIT_MGMT.AUDIT_TRAIL_DB_STD: Both standard and fine-grained audit trail tables. (This setting does not apply to read-only databases) -
DBMS_AUDIT_MGMT.AUDIT_TRAIL_OS: Operating system audit trail files with the.audextension. (This setting does not apply to Windows Event Log entries.) -
DBMS_AUDIT_MGMT.AUDIT_TRAIL_XML: XML Operating system audit trail files. -
DBMS_AUDIT_MGMT.AUDIT_TRAIL_FILES: Both operating system and XML audit trail files. -
DBMS_AUDIT_MGMT.AUDIT_TRAIL_ALL: All audit trail records, that is, both database audit trail and operating system audit trail types. (This setting does not apply to read-only databases.)
To purge records from the
AUDSYS.AUD$UNIFIEDtable or from the operating system spillover files:-
DBMS_AUDIT_MGMT.AUDIT_TRAIL_UNIFIED_TABLEpurges records from theAUDSYS.AUD$UNIFIEDtable. -
DBMS_AUDIT_MGMT.AUDIT_TRAIL_UNIFIED_FILESpurges records from the operating system spillover files in each database (primary or standby).
-
-
USE_LAST_ARCH_TIMESTAMP: Enter either of the following settings:-
TRUE: Deletes audit records created before the last archive timestamp. The default (and recommended) value isTRUE. Oracle recommends that you setUSE_LAST_ARCH_TIMESTAMPtoTRUE. -
FALSE: Deletes all audit records without considering last archive timestamp. Be careful about using this setting, in case you inadvertently delete audit records that should not have been deleted.
-
-
CONTAINER: Applies the cleansing to either the current PDB or to all PDBs.DBMS_AUDIT_MGMT.CONTAINER_CURRENTspecifies the current PDB;DBMS_AUDIT_MGMT.CONTAINER_ALLapplies to all PDBs. -
DROP_PARTITION_ONLY: Specifies whetherCLEAN_AUDIT_TRAILskips row deletion and drops only eligible partitions of the unified audit trail table (AUDSYS.AUD$UNIFIED). This parameter applies only whenAUDIT_TRAIL_TYPEspecifies the unified audit trail.-
FALSEdeletes all audit records created before the last archive timestamp, subject to the other parameter values. Use this value when cleanup must remove all audit records created before the last archive timestamp. -
TRUEskips row-by-row deletion and drops only partitions ofAUDSYS.AUD$UNIFIEDthat are before the last archive timestamp. This can improve cleanup performance significantly. However, audit records that are older than the last archive timestamp can remain in the current partition after cleanup.
-
Related Topics