The database initialization parameter AUDIT_TRAIL controls the enabling and disabling of auditing. The default setting for this parameter is NONE, which means that no auditing will be performed, regardless of whether or not AUDIT commands are issued. It is important to remember that any auditing statements issued will not be performed if AUDIT_TRAIL=NONE. Unless auditing is enabled in the database parameter initialization file, any auditing options that have been turned on will not create records in the audit trail. Auditing is not completely disabled unless it is set to NONE in the database parameter initialization file.You must set the database initialization parameter AUDIT_TRAIL to DB or OS to enable auditing. The DB setting means the audit trail records are stored in the database in the SYS.AUD$ table. OS will send the audit trail records to an operating system file. The OS setting is operating system-dependent and is not supported on all operating systems. Auditing can be performed based on whether statements are executed successfully or unsuccessfully. Auditing WHEN SUCCESSFUL inserts records into the audit trail only if the SQL command executes successfully. Auditing WHEN NOT SUCCESSFUL inserts records into the audit trail only when the SQL statement is unsuccessful. If a statement is unsuccessful due to syntax errors, it will not be included in the audit trail. If neither WHEN SUCCESSFUL nor WHEN NOT SUCCESSFUL is specified, both successful and unsuccessful actions will be audited.Auditing can be set using BY SESSION or BY ACCESS. When you use the BY SESSION option for statement or privilege auditing, the audit proces writes a single record to the audit trail when a connection is made. When the session is disconnected, that record is updated with cumulative information about the session. The information collected includes connection time, disconnection time, and logical and physical I/Os processed. Audit options set using BY SESSION for objects insert one record per database object into the audit trail for each session. When you set auditing using BY ACCESS, a record is inserted into the audit trail for each statement issued. All auditing of DDL statements will be audited using BY ACCESS regardless of whether you have set auditing using BY ACCESS or BY SESSION.The BY USER option enables you to limit auditing to a specific user or list of users. When you do not specify BY USER, all users will be audited. 
When you change auditing options, they become active for subsequent sessions, not current sessions. Any existing sessions will continue to use the auditing options in effect when the existing sessions logged into the database. Here is an example: AUDIT DELETE TABLE, INSERT TABLE,
EXECUTE ANY PROCEDURE
BY beth
BY ACCESS 
WHENEVER SUCCESSFUL;

解决方案 »

  1.   

    感谢答复。
    (能否详细一点,我是指具体操作,而不是概念上的宏观讲解)我试了,得到如下报错信息。
    EXECUTE ANY PROCEDURE
    *
    ERROR 位于第 2 行:
    ORA-00981: 不能将表和系统审计选项混在一起
      

  2.   

    1、审计的设置
    在ORACLE734中,查找INITORCLE.ORA文件,将其中的audit_trail = true            # if you want auditing
    2、分别执行以下的SQL(以DBA用户登陆系统)
    2、1 #审计注册企图
    AUDIT SESSION; #开始审计注册企图成功失败都记录,审计记录放在SYS.AUD$表中,也可以通过该表的视图DBA_AUDIT_SESSION数据字典视图查看
    AUDIT SEEION WHENEVER SUCCESSFUL;# 仅审计连接企图成功
    AUDIT SEEION WHENEVER NOT SUCCESSFUL; # 仅审计连接企图失败
    SELECT OS_USERNAME,USERNAME,TERMINAL,DECODE(RETURNCODE,'0','CONNECTED','1005','FAILEDNULL','10017','FAILED',RETURNCODE),TO_CHAR (TIMESTAMP,'DD-MON-YY HH24:MI:SS'),TO_CHAR (LOGOFF_TIME,'DD-MON-YY HH24:MI:SS') FROM DBA_AUDIT_SESSION ;
    NOAUDIT SESSION;# 禁止审计
    2、2 操作审计
    #审计表的操作
    AUDIT TABLE;#只审计CREATE、DROP、ALTER、TRUNCATE(??似乎ALTER不能审计??)
    AUDIT SELECT TABLE, UPDATE TABLE BY scott, blake #审计SELECT、UPDATE 用户SCOTT和BLAKE 中的 表
    AUDIT ROLE;  #审计角色(ROLE),;
    AUDIT SYSTEM GRANT;#审计系统权限和角色(SYSTEM GRANT)的审计或不审计,
    AUDIT USER;  #审计用户(USER)的CREATE\ALTER和DROP
    NOAUDIT ** 禁止审计**
    SELECT OS_USERNAME,USERNAME,TERMINAL,OWNER,OBJ_NAME,ACTION_NAME,DECODE(RETURNCODE,'0','SUCCESS',RETURNCODE),TO_CHAR (TIMESTAMP,'DD-MON-YY HH24:MI:SS') FROM DBA_AUDIT_OBJECT;
    #关于出错代码的说明请参阅ORACLE734中的SERVER MESSAGES中的相应代码
    2、4 对象审计
    AUDIT INSERT ON TEST.CAR; 默认是的BY SESSION;
    AUDIT ALL ON TSET.CAR BY ACCESS ;对TEST用户下的CAR表的SELECT\INSERT\UPDATE\DELETE 都进行审计,每次访问对象都进行审计
    SELECT OS_USERNAME,USERNAME,TERMINAL,OWNER,OBJ_NAME,ACTION_NAME,DECODE(RETURNCODE,'0','SUCCESS',RETURNCODE),TO_CHAR (TIMESTAMP,'DD-MON-YY HH24:MI:SS') FROM DBA_AUDIT_OBJECT;


    3、审计记录的管理
    删除:
    DELETE FROM SYS.AUD$;
    COMMIT;
    需要注意的几点问题:
    1、每次数据库启动后,执行AUDIT ** 语句,将希望审计的注册、操作、对象执行一次;
    2、需要检查审计记录的时候,执行查询语句。
    3、审计结束后,对审计记录进行管理(删除、备份)ORACLE 8 也差不多