Audit all insert, delete, update and select statements on a schema in Oracle 12.2

auditoracle-12c

I cannot understand how to create a Unified Audit policy in order to audit all INSERT, UPDATE, DELETE and SELECT statements performed on all the objects within a specific schema.

The goal is to track the tables and views involved in a specific PL/SQL procedure for a reverse engineering task.

For what I understood from the documentation, the only option is to specify each table/view to track within the policy. Is there an "audit all objects within a schema" construct for the create audit policy statement?

Best Answer

There is no "audit all objects" setting. In unified auditing, do the following:

-- create the policy
create audit policy my_policy actions all on hr.regions;
alter audit policy my_policy actions all on hr.locations;
...

-- enable the policy
audit policy my_policy;

if you have a schema with a lot of tables, you can use SQL to build your script with something like this:

select 'alter audit policy hr_policy actions all on '||owner||'.'||table_name||';'
  from dba_tables
 where owner in ('HR','OE');