Auditing Features  «Prev  Next»

Lesson 7 Auditing access to schema objects
Objective Audit the Use of Database Objects in Oracle.

Audit the Use of Database Objects in Oracle

As an Oracle Database Administrator (DBA), auditing the use of database objects is a crucial aspect of your role, ensuring security and compliance within the database environment. Oracle provides robust tools for this purpose, and the process involves several key steps:
  1. Enable Auditing: First, ensure that auditing is enabled in your Oracle database. This is achieved by setting the `AUDIT_TRAIL` parameter in the database initialization file (init.ora or spfile.ora). You can set this parameter to various levels, such as `DB`, `DB, EXTENDED`, or `XML`. For example:
    ALTER SYSTEM SET AUDIT_TRAIL=DB SCOPE=SPFILE;
    

    After setting this parameter, restart the database to activate auditing.
  2. Decide on Auditing Scope: Determine which database objects and types of actions you need to audit. Oracle allows auditing at various levels, including specific tables, schemas, or types of SQL statements.
  3. Implement Standard Auditing: Use the `AUDIT` SQL statement to specify what activities you want to monitor. For instance, to audit all SELECT, INSERT, UPDATE, and DELETE operations on a specific table, use:
    AUDIT SELECT, INSERT, UPDATE, DELETE ON schema.table BY ACCESS;
    

    Replace `schema.table` with the appropriate schema name and table name.
  4. Fine-Grained Auditing (FGA): For more detailed auditing requirements, use Oracle's Fine-Grained Auditing feature. This allows you to specify conditions under which audits should occur. FGA is particularly useful for monitoring access to sensitive data. Implement FGA using the `DBMS_FGA` package. For example:
    BEGIN
    DBMS_FGA.ADD_POLICY(
    object_schema   => 'schema_name',
    object_name     => 'table_name',
    policy_name     => 'policy_name',
    audit_condition => 'column_name=''''value''''',
    audit_column    => 'column_name',
    handler_schema  => NULL,
    handler_module  => NULL,
    enable          => TRUE);
    END;
    

    Adjust the parameters according to your auditing requirements.
  5. Review Audit Records: Audit records are stored in audit trail views such as `DBA_AUDIT_TRAIL`, `DBA_COMMON_AUDIT_TRAIL` (for unified auditing), or `DBA_FGA_AUDIT_TRAIL` (for FGA). Regularly review these views to monitor database activities. Use SQL queries to filter and analyze the data based on your reporting needs.
  6. Manage Audit Trail Size: Monitor the size of the audit trail. Regularly archive and purge old audit data to prevent excessive growth, which can impact database performance.
  7. Ensure Compliance and Security: Regularly review your auditing configuration to ensure it aligns with organizational policies, regulatory requirements, and security best practices. Secure access to the audit data to prevent unauthorized use or modification.
  8. Document and Report: Maintain documentation of your auditing policies, procedures, and findings. Generate reports as required for compliance, internal audits, or security reviews.
  9. Stay Updated: Keep abreast of updates and best practices in Oracle database auditing. Oracle periodically releases updates and patches that may include enhancements or changes to auditing features.

By diligently following these steps, you can effectively audit the use of database objects in Oracle, thereby enhancing the security, compliance, and overall integrity of your database environment.


The final area that you can audit is the use of database objects. Auditing database objects in a particular schema is the most limited form of auditing, because you direct the audit process to a single object or group of objects. Auditing database objects is frequently used to analyze usage characteristics that may affect performance, as well as to watch for security violations.

Syntax

The syntax for specifying auditing on schema objects is very similar to the syntax described for the other auditing options. To audit a specific type of statement on a particular object, use the syntax
AUDIT statement ON object_name

where statement is any SQL statement and object_name is the name of the object to be audited. If the object is in the current schema, you do not have to specify a schema name; if not, you will have to use the notation schema.object_name. You can two of the same options for auditing database objects that you can for auditing other types of SQL statements, such as BY SESSION/ACCESS and WHENEVER [NOT] SUCCESSFUL. You cannot use the BY USER clause if you are auditing a specific database object.


Default Auditing

There may be times when you want to specify a standard type of auditing for any objects that are created in a schema in the future. You can use the ON DEFAULT clause to indicate the statements you want to audit.
For instance, if you want to audit all INSERT, UPDATE, and DELETE statements issued against any objects created in the schema, use the command
AUDIT INSERT, UPDATE, DELETE ON DEFAULT;

This automatically turns on auditing on all INSERT, UPDATE, and DELETE statements for all objects subsequently created in the schema. To change the audits on these new objects, you would have to issue an overriding AUDIT statement for the object or use the NOAUDIT command to remove the auditing option. In the next lesson, you will learn how to get rid of audit records you no longer need.

SEMrush Software