← Security
Oracle · Security

How to create and enable a Unified Auditing policy in Oracle

Create a Unified Auditing policy with CREATE AUDIT POLICY and turn it on with AUDIT POLICY, then verify it is enabled.

Tested on12c18c19c21c23ai26ai

Create a Unified Auditing policy and enable it, for example to record logon and logoff activity.

This changes what the database audits and starts writing new audit records. Define the actions to your needs and enable it deliberately.

-- Create the policy (example: logon / logoff)
CREATE AUDIT POLICY &&policy_name
  ACTIONS LOGON, LOGOFF;

-- Enable it (here: only failed attempts)
AUDIT POLICY &policy_name WHENEVER NOT SUCCESSFUL;

-- Verify (read-only)
SELECT policy_name, enabled_option, entity_name, success, failure
FROM   audit_unified_enabled_policies
WHERE  policy_name = UPPER('&policy_name');
SecurityAuditingCREATE AUDIT POLICY