Oracle審計語句簡單使用(1)

來源:互聯網
上載者:User

審計(Audit)用於監視使用者所執行的資料庫操作,並且Oracle會將審計跟蹤結果存放到OS檔案或資料庫中。

1、使用審計,需要啟用審計

SQL> conn /as sysdba 已串連。 SQL> show parameter audit_sys_operations;    NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ audit_sys_operations boolean FALSE SQL> show parameter audit_trail; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ audit_trail string NONE SQL> alter system set audit_sys_operations=TRUE scope=spfile; 系統已更改。 SQL> alter system set audit_trail=db scope=spfile; 系統已更改。 SQL> startup force ORACLE 常式已經啟動。 Total System Global Area 289406976 bytes Fixed Size 1248576 bytes Variable Size 79692480 bytes Database Buffers 201326592 bytes Redo Buffers 7139328 bytes 資料庫裝載完畢。 資料庫已經開啟。 SQL> show parameter audit; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ audit_file_dest string D:\ORACLE\PRODUCT\10.2.0\ADMIN \ORCL\ADUMP audit_sys_operations boolean TRUE audit_trail string DB

2、審計dept表

SQL> audit all on dept; 審計已成功。 SQL> conn mzl/mzl 已串連。 SQL> select * from dept; DEPTNO DNAME LOC ---------- -------------- ------------- 10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS PanJin 80 mengzhaoliang beijing SQL> insert into dept 2 values (90,'test','PanJin'); 已建立 1 行。 SQL> commit; 提交完成。 SQL> conn scott/mzl 已串連。 SQL> insert into dept 2 values(60,'June','ShangHai'); 已建立 1 行。 SQL> commit; 提交完成。

3、查看審計結果

SQL> conn /as sysdba 已串連。 SQL> select count(*) from dba_audit_trail; COUNT(*) ---------- 2 SQL> select username,ses_actions,obj_name, 2 to_char(timestamp,'YYYY-MM-DD HH24:MI:SS') 3 from dba_audit_trail; USERNAME SES_ACTIONS ------------------------------ ------------------- OBJ_NAME -------------------------------------------------------------------------------- TO_CHAR(TIMESTAMP,' ------------------- MZL ------S--S------ DEPT 2008-10-20 10:28:08 SCOTT ------B--------- DEPT 2008-10-20 10:29:04 USERNAME SES_ACTIONS ------------------------------ ------------------- OBJ_NAME -------------------------------------------------------------------------------- TO_CHAR(TIMESTAMP,' ------------------- SQL> conn mzl/mzl 已串連。


相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.