Auditing Oracle Machine Learning for SQL Events

You can use the CREATE AUDIT POLICY statement to audit Oracle Machine Learning for SQL events.

About Auditing Oracle Machine Learning for SQL Events

You must have the AUDIT_ADMIN role to audit Oracle Machine Learning for SQL events.

To access the audit trail, you can query the UNIFIED_AUDIT_TRAIL data dictionary view.

Related Topics

Oracle Machine Learning for SQL Unified Audit Trail Events

The unified audit trail can capture Oracle Machine Learning for SQL audit events.. The following table describes these events.

Audit Event Description
AUDIT Generates an audit record for a Oracle Machine Learning for SQL model
COMMENT Adds a comment to a Oracle Machine Learning for SQL model
GRANT Gives permission to a user to access the Oracle Machine Learning for SQL model
RENAME Changes the name of the Oracle Machine Learning for SQL model
SELECT Applies the Oracle Machine Learning for SQL model or view its signature

Configuring a Unified Audit Policy for Oracle Machine Learning for SQL

The CREATE AUDIT POLICY statement ACTIONS and ON MINING MODEL clauses can be used to create Oracle Machine Learning for SQL event unified audit policies.

Use the following syntax to create a unified audit policy for Oracle Machine Learning for SQL:

CREATE AUDIT POLICY policy_name
ACTIONS {operation | ALL}
ON MINING MODEL schema_name.model_name;

For example:

CREATE AUDIT POLICY dm_ops ACTIONS RENAME ON MINING MODEL hr.dm_emp;

You can build more complex policies, such as those that include conditions. Remember that after you create the policy, you must use the AUDIT statement to enable it.

Related Topics

Example: Auditing Multiple Oracle Machine Learning for SQL Operations by a User

The CREATE AUDIT POLICY statement can audit multiple Oracle Machine Learning for SQL operations. The following example shows how to audit multiple Oracle Machine Learning for SQL operations by user psmith. Include the ON MINING MODEL schema_name.model_name clause for each event, and separate each with a comma. This example specifies the same schema_name.model name for both actions, but the syntax enables you to specify different schema_name.model_name settings for different schemas and data models.

CREATE AUDIT POLICY dm_ops_pol
ACTIONS SELECT ON MINING MODEL dmuser1.nb_model, ALTER ON MINING MODEL dmuser1.nb_model;

AUDIT POLICY dm_ops_pol BY psmith;

Example: Auditing All Failed Oracle Machine Learning for SQL Operations by a User

The CREATE AUDIT POLICY statement can audit failed Oracle Machine Learning for SQL operations by a user. The following example shows how to audit all failed Oracle Machine Learning for SQL operations by user psmith.

CREATE AUDIT POLICY dm_all_ops_pol ACTIONS ALL ON MINING MODEL dmuser1.nb_model;

AUDIT POLICY dm_all_ops_pol BY psmith WHENEVER NOT SUCCESSFUL;

How Oracle Machine Learning for SQL Events Appear in the Audit Trail

The UNIFIED_AUDIT_TRAIL data dictionary view lists Oracle Machine Learning for SQL audit events.

The following example shows how to query the UNIFIED_AUDIT_TRAIL data dictionary view for Machine Learning for SQL audit events.

SELECT DBUSERNAME, ACTION_NAME, SYSTEM_PRIVILEGE_USED, RETURN_CODE,
OBJECT_SCHEMA, OBJECT_NAME, SQL_TEXT
FROM UNIFIED_AUDIT_TRAIL;

DBUSERNAME ACTION_NAME          SYSTEM_PRIVILEGE_USED     RETURN_CODE
---------- -------------------- ------------------------- -----------
OBJECT_SCHEMA        OBJECT_NAME
-------------------- --------------------
SQL_TEXT
--------------------------------------------------------------------------------
DMUSER1    CREATE MINING MODEL  CREATE MINING MODEL                 0
DMUSER1
BEGIN
  dbms_data_mining.create_model(model_name => 'nb_model',
                mining_function => dbms_data_mining.classification,
                data_table_name => 'dm_data',
                case_id_column_name => 'case_id',
                target_column_name => 'target');
END;

DMUSER1    SELECT MINING MODEL                                      0
DMUSER1              NB_MODEL
select prediction(nb_model using *) from dual

DMUSER2    SELECT MINING MODEL                                  40284
DMUSER1              NB_MODEL
select prediction(dmuser1.nb_model using *) from dual

DMUSER1    ALTER MINING MODEL                                       0
DMUSER1              NB_MODEL
BEGIN dbms_data_mining.rename_model('nb_model', 'nb_model1'); END;

DMUSER2    ALTER MINING MODEL                                   40284
DMUSER1              NB_MODEL
BEGIN dbms_data_mining.rename_model('dmuser1.nb_model1', 'nb_model'); END;

DMUSER2    ALTER MINING MODEL                                   40284
DMUSER1              NB_MODEL
BEGIN dbms_data_mining.rename_model('dmuser1.nb_model1', 'nb_model'); END;

Managing Unified Audit Policies

After you create a unified audit policy, you must enable it. You can alter disable, and drop unified audit policies.