Oracle Fine Grained Auditing for entire schema

拈花ヽ惹草 提交于 2019-12-12 10:17:10

问题


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?


回答1:


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;
/


来源:https://stackoverflow.com/questions/13257086/oracle-fine-grained-auditing-for-entire-schema

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!