Statement specific auditing – Oracle

auditoracleoracle-11g-r2

I have enabled default auditing in one of my database. Oracle 11g. Audit_trail is set to DB, other than that for a particular schema 'test' I have set:

audit all on test by access

With the above setting, I know I can get to know what action has been performed (alter,create,update,etc) but will I be able to fetch the SQL statments (all DML operations) with the exact SQL statement fired from that schema from the audit records? Let me know how?

If the above is not possible, what is required to fetch the exact SQL statement that is run by the schema.

Best Answer

AUDIT_TRAIL

If you want the SQL text to be captured, you need to use the extended option for audit_trail (db, extended or xml, extended).

alter system set AUDIT_TRAIL=db, extended scope=spfile;

or

alter system set AUDIT_TRAIL=xml, extended scope=spfile;

Changing this setting requires a database restart to take effect.

For FGA you can specify a different audit trail, for example: audit_trail => DBMS_FGA.DB_EXTENDED, that way you can leave audit_trail on DB. If you use FGA, you do not even need to use AUDIT, just create the policy you need.