10g初始化引數AUDIT_TRAIL變化(二)

yangtingkun發表於2010-12-07

9i中,初始化引數AUDIT_TRAIL只有NONEDBOS三個可選值,而在10g中,Oracle又增加了幾個新的選項。

這篇介紹EXTEND選項。

10g初始化引數AUDIT_TRAIL變化(一):http://yangtingkun.itpub.net/post/468/510039

 

 

當前資料庫的設定為:

SQL> show parameter audit_trail

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
audit_trail                          string      XML

檢查一下這種情況下對SQL語句和繫結變數的支援:

SQL> var v_id number
SQL> exec :v_id := 1

PL/SQL procedure successfully completed.

SQL> audit select on t_audit;                                  

Audit succeeded.

SQL> select * from t_audit where id = :v_id;

no rows selected

查詢V$XML_AUDIT_TRAIL檢視:

SQL> select db_user, object_name, sql_text, sql_bind
  2  from v$xml_audit_trail;

DB_USER  OBJECT_NAME  SQL_TEXT                                           SQL_BIND
-------- ------------ -------------------------------------------------- ----------
/                     CONNECT
/                     CONNECT
/                     CONNECT
TEST     T_AUDIT
TEST     T_AUDIT

對於新執行的SELECT語句,看不到SQL語句和繫結變數,下面設定AUDIT_TRAIL引數為XML, EXTENDED

SQL> conn / as sysdba
Connected.

SQL> alter system set audit_trail = xml, extended scope = spfile;

System altered.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area 2147483648 bytes
Fixed Size                  2074112 bytes
Variable Size             486541824 bytes
Database Buffers         1644167168 bytes
Redo Buffers               14700544 bytes
Database mounted.
Database opened.

下面執行同樣的查詢語句:

SQL> conn test/test
Connected.
SQL> select * from t_audit where id = :v_id;

no rows selected

SQL> select db_user, object_name, sql_text, sql_bind
  2  from v$xml_audit_trail;

DB_USER  OBJECT_NAME  SQL_TEXT                                           SQL_BIND
-------- ------------ -------------------------------------------------- ----------
/                     CONNECT
/                     CONNECT
/                     CONNECT
/                     SHUTDOWN
/                     CONNECT
TEST     T_AUDIT
TEST     T_AUDIT
TEST     T_AUDIT      select * from t_audit where id = :v_id              #1(1):1

8 rows selected.

可以看到,設定了AUDIT_TRAILXML, EXTENDED引數後,資料庫不僅記錄下複合AUDIT條件的SQL語句,設定還會記錄SQL語句中使用的繫結變數。

不過需要注意的是,這種審計同時也存在暴露敏感SQL語句以及敏感資料的潛在危險,同時記錄SQL語句和繫結變數勢必增加額外的開銷,因此這個選項應該只在需要的時候開啟。

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/4227/viewspace-681122/,如需轉載,請註明出處,否則將追究法律責任。

相關文章