Simple use of Oracle audit statements (1)

Source: Internet
Author: User

Audit is used to monitor the database operations performed by users. Oracle stores Audit trail results in OS files or databases.

1. To use audit, you must activate audit.

SQL> conn/as sysdba is connected. 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; the system has changed. SQL> alter system set audit_trail = db scope = spfile; the system has been changed. SQL> startup force ORACLE routine has been started. Total System Global Area 289406976 bytes Fixed Size 1248576 bytes Variable Size 79692480 bytes Database Buffers 201326592 bytes Redo Buffers 7139328 bytes Database load is complete. The database has been opened. 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. Audit The dept table

SQL> audit all on dept; audit successful. SQL> conn mzl/mzl is connected. 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 row has been created. SQL> commit; submitted completely. SQL> conn scott/mzl is connected. SQL> insert into dept 2 values (60, 'june', 'shanghai'); 1 row has been created. SQL> commit; submitted completely.

3. View audit results

SQL> conn/as sysdba is connected. 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 defaults TO_CHAR (TIMESTAMP,' ------------------- MZL ------ S--S ------ DEPT 10:28:08 SCOTT ------ B --------- DEPT 10:29:04 USERNAME SES_ACTIONS =--------------------- OBJ_NAME =to_char (TIMESTAMP, '------------------- SQL> conn mzl/mzl connected.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.