Oracle provides the ability to audit a great range of activities within the Oracle RDBMS environment. Care should be taken on what you wish to audit, due to the amount of disk space required to store all of this information. In this article we will discuss the auditing of insert, update, and deletes by user account access.
1. Logon to SQL*PLUS as sysdba
mylinux:>sqlplus ‘/ as sysdba’
SQL*Plus: Release 10.2.0.4.0 – Production on Fri Jul 03 19:18:21 2009
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
2. Ensure that audit_trail is set to DB_EXTENDED and audit_sys_operations parameter is set to TRUE. Note: It is important to realize that setting the AUDIT_TRAIL to DB_EXTENDED will dramatically increase storage, so monitor this closely.
SQL> show parameter audit
NAME TYPE VALUE
———————————— ———– ——————————
audit_file_dest string /U01/ORACLE/PRODUCT/10.2.0/ADMIN
/ORCL10G/ADUMP
audit_sys_operations boolean FALSE
audit_trail string NONE
SQL>
System altered.
SQL> alter system set audit_sys_operations= TRUE scope=spfile;
System altered.
SQL>
3. Restart the database if you had to edit the init parameters.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup open
ORACLE instance started.
Total System Global Area 612368384 bytes
Fixed Size 1250428 bytes
Variable Size 209718148 bytes
Database Buffers 394264576 bytes
Redo Buffers 7135232 bytes
Database mounted.
Database opened.
SQL>
4. Ensure that the new values took effect.
SQL> show parameter audit
NAME TYPE VALUE
———————————— ———– ——————————
audit_file_dest string /U01/ORACLE/PRODUCT/10.2.0/ADMIN
/ORCL10G/ADUMP
audit_sys_operations boolean TRUE
audit_trail string TRUE
SQL>
5. Execute the audit command below to begin monitoring changes to the table SCOTT.DEPT.
SQL> audit insert, update, delete on scott.dept by session;
Audit succeeded.
SQL>
6. Connect to the database as the user LJCATT and perform a insert, update and delete operation on the table scott.dept.
SQL> connect ljcatt/ljcatt
Connected.
SQL> insert into scott.dept(deptno, dname, loc) values(50,’PARTNERS’,’NEW YORK’)
;
1 row created.
SQL> commit;
Commit complete.
SQL> update scott.dept set loc=’WASHINGTON’ where deptno=50;
1 row updated.
SQL> commit;
Commit complete.
SQL> delete from scott.dept where deptno=50;
1 row deleted.
SQL> commit;
Commit complete.
SQL>
7. Login as sysdba again.
SQL> connect sys as sysdba
SQL>
8. Execute the following SQL to extract the statements executed by LJCATT.
“select timestamp, sql_text from dba_audit_object where username=’LJCATT’;â€
SQL> select timestamp, sql_text from dba_audit_object where username=’LJCATT’;
TIMESTAMP SQL_TEXT
——— ——————————————————-
27-AUG-09 update scott.dept set loc=’WASHINGTON’ where deptno=50
27-AUG-09 insert into scott.dept(deptno, dname, loc) values(50,’PARTNERS’,’NEW YORK’)
27-AUG-09 delete from scott.dept where deptno=50
SQL>
9. That completes the use of Oracle Auditing to monitor the changes to the Oracle database by users.
Larry J. Catt, OCP 9i, 10g
oracle@allcompute.com
www.allcompute.com