Question

I need to log all sql queries running in an Oracle database I have (non-production, running Oracle 11g enterprise). How I would like to do this, is to use Oracle's Fine Grained Auditing, since it logs the exact query and does so in the db, which is much more useful for me. However , it seems from the documentation (http://docs.oracle.com/cd/B19306_01/network.102/b14266/cfgaudit.htm#i1011783) that you are required to specify a table name, with no default.

Is it possible to use Oracle fine grained auditing to audit all queries on a schema?

Was it helpful?

Solution

Disable auditing:

begin
    for c1 in (select * from dba_audit_policies) loop
        dbms_fga.drop_policy (
            object_schema => c1.object_schema,
            object_name   => c1.object_name,
            policy_name   => c1.policy_name);
    end loop;
end;
/

Enable auditing for entire schema:

begin
    for c1 in (select * from all_tables where owner = '&schema') loop
        dbms_fga.add_policy (
            object_schema   => c1.owner,
            object_name     => c1.table_name,
            statement_types => 'SELECT,UPDATE,DELETE,INSERT',
            policy_name     => c1.table_name
        );
    end loop;
end;
/
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top