Learn when you want, where you want with convenient online training courses. Sign up now!
Experts Exchange Solution brought to you by
"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.
-- FGA example // mrjoltcola
-- Use the EMP schema (SCOTT/TIGER) to demonstrate fine-grained auditing
-- Create SCOTT schema if you haven't yet
-- Check database to see if both AUDITING and/or FGA support is setup
show parameter audit
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
audit_file_dest string C:\ORACLE\ADMIN\DEV\ADUMP
audit_sys_operations boolean FALSE
audit_trail string NONE
-- We don't have to have standard auditing on, but to use standard auditing, but set AUDIT_TRAIL above
-- to db_extended so we get fine grained audit plus SQL_BIND, (bind vars) and SQL_TEXT auditing
-- which is important for this purpose. Then restart database
ALTER SYSTEM SET audit_trail=db_extended SCOPE=SPFILE;
-- To use FGA, we use FGA policies
-- Add a SALARY policy to the EMP table
-- Run as SYS or another user with execute on package dbms_fga
-- Default action is to audit SELECT but with 10g we can add DML actions by adding to statement_types parameter
-- Setup a policy to audit access of Employee Salaries
audit_condition => NULL, -- TRUE
audit_column => 'SAL',
statement_types => 'SELECT,INSERT,UPDATE,DELETE'
-- Scott selects salaries and then gives self a raise
select * from emp;
update emp set sal = 30000 where ename = 'SCOTT';
-- DBA connects and checks audit trail
connect / as sysdba
-- Find who ran what against EMP table
select timestamp, db_user, sql_text from dba_fga_audit_trail where object_name = 'EMP';
/* You will see...
01-APR-09 SCOTT select * from emp
01-APR-09 SCOTT update emp set sal = 30000 where ename = 'SCOTT'
Open in new window
Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.