SET_LAST_ARCHIVE_TIMESTAMP

2024-04-19 08:42:50  Updated

The SET_LAST_ARCHIVE_TIMESTAMP procedure sets the timestamp that indicates when audit records were last archived. The audit administrator provides the timestamp to be attached to the audit records. The CLEAN_AUDIT_TRAIL procedure decides on the audit records to be deleted based on this timestamp.

Applicability

This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only the MySQL mode.

Syntax

DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP(
audit_trail_type         IN PLS_INTEGER,
last_archive_time        IN TIMESTAMP,
rac_instance_number      IN PLS_INTEGER DEFAULT NULL);

Parameters

Parameter Description
audit_trail_type The audit trail type of the purge job. For more information about audit trail types, see Audit trail types.
last_archive_time The timestamp for determining the audit records or files to be deleted. This value indicates the last time when audit records or files are archived.
rac_instance_number The instance number. Default value: NULL. The rac_instance_number parameter is invalid when audit_trail_type is set to any of the following values:
  • audit_trail_all
  • audit_trail_aud_std
  • audit_trail_db_std
For a single-instance database, set rac_instance_number to 1.

Considerations

When the audit trail type is AUDIT_TRAIL_AUD_STD, the value of last_archive_time must be Universal Time Coordinated (UTC). This is because audit trail timestamps are stored in UTC format in the database. UTC is also known as Greenwich Mean Time (GMT).

When the audit trail type is AUDIT_TRAIL_OS, the value of last_archive_time must be the time in the local time zone. The time zone must be the one to which the server where the OS audit files are created belongs. This is because OS audit files are purged based on their last modification timestamps. The last modification timestamp is stored in the local time zone of the server.

Examples

The following example calls the SET_LAST_ARCHIVE_TIMESTAMP procedure to set the last archive timestamp for the OS audit trail records on a database instance, and uses the TO_TIMESTAMP function to convert the string into a timestamp.

Then, it calls the CLEAN_AUDIT_TRAIL procedure and sets use_last_arch_timestamp to TRUE to delete all OS audit files that were modified before 11:11:11.11 November 11, 2021 from the current directory.

BEGIN
   DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP(
      audit_trail_type     => DBMS_AUDIT_MGMT.AUDIT_TRAIL_OS,
      last_archive_time    => TO_TIMESTAMP ('2021-11-11 11:11:11.11', 'YYYY-MM-DD HH24:MI:SS.FF')
      rac_instance_number  => 1);
END;

Contact Us