我需要记录在我拥有的Oracle数据库中运行的所有sql查询(非生产,运行Oracle 11g企业)。我想这样做,就是使用Oracle的细粒度审计,因为它记录了确切的查询,并在db中这样做,这对我来说更有用。但是,从文档(http://docs.oracle.com/cd/B19306_01/network.102/b14266/cfgaudit.htm#i1011783)中可以看出,您需要指定一个表名,没有默认值。
是否可以使用Oracle细粒度审计来审核架构上的所有查询?
答案 0 :(得分:3)
禁用审核:
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;
/
启用整个架构的审核:
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;
/