Oracle Database Administration, one of the important utility FGA for auditing in database.
Use 7 simple steps to learn FGA.
1 of 13
Download to read offline
More Related Content
simple 7 Steps to learn Fine grained auditing.
1. Fine GrainedAuditing
Step1. Createuserzoe assign10monuser.
SQL> create user zoe identified by zoe
2 default tablespace users
3 temporary tablespace temp
4 quota 10m on users
5 account unlock;
User created.
SQL> grant connect,create table,resource tozoe;
Grant succeeded.
Step2. Make a table toys, and insertsome rows.
SQL> conn zoe/zoe;
Connected.
SQL> create table toy
2 (toynonumber(2),
3 name varchar(10),
4 cost number(5),
5 manf char(10) );
Table created.
SQL> desc toy;
Name Null? Type
----------------------------------------- -------- ----------------------------
TOYNO NUMBER(2)
NAME VARCHAR2(10)
COST NUMBER(5)
MANF CHAR(10)
SQL> insertintotoy values
2 (01, 'bugati',2500,'italy');
1 rowcreated.
SQL> insertintotoy values
2 (02,'cameross', 2000, 'chevy');
1 rowcreated.
SQL> commit; ---- insertsome more rows.
Commitcomplete.
2. SQL> select * from toy;
TOYNONAME COST MANF
----------------------------------------
3 charger 1500 dodge
4 plymounth 1200 plymounth
5 landcruser 2000 toyota
6 audi ax 1400 audi
7 mustang 2200 ford
8 trino 1800 ford
9 challenger 1900 dodge
10 mursilago 2800 lamorghini
11 golorado 2300 lamorghini
12 civic 1200 honda
1 bugati 2500 italy
TOYNONAME COST MANF
----------------------------------------
2 camero ss 2000 chevy
12 rows selected.
Step3. AssignFGAprivilegeto zoe.
SQL> conn / as sysdba
Connected.
SQL> grant EXECUTE ONdbms_fgato zoe;
Grant succeeded.
Step4. Createusersasha, jiyaandassign5m each onuser.
SQL> showuser
USER is"SYS"
SQL> create usersashaidentifiedbysasha
2 defaulttablespace users
3 temporarytablespace temp
4 quota5m onusers
5 account unlock;
User created.
SQL> create userjiyaidentifiedbyjiya
2 defaulttablespace users
3 temporarytablespace temp
4 quota5m onusers
5 account unlock;
3. User created.
SQL> grant connect,resource to sasha;
Grant succeeded.
SQL> grant connect,resource to jiya;
Grant succeeded.
Step5. GrantTOY tableto sasha, jiya.
SQL> conn zoe/zoe;
Connected.
SQL> grant select, insert, update on toy to jiya;
Grant succeeded.
SQL> grant select , insert, update on toy to sasha;
Grant succeeded.
SQL> conn sasha/sasha
Connected.
SQL> select* from zoe.toy; ---sashacan accesstoy table fromzoe.
TOYNONAME COST MANF
---------- -------------------- ----------
3 charger 1500 dodge
4 plymounth 1200 plymounth
5 landcruser 2000 toyota
6 audi ax 1400 audi
7 mustang 2200 ford
6. --- Zoe put the conditionto auditthe query which return the nameof car which cost>=1500. Every
select commandfor that condition, auditwill alsorecord insert, updateand delete commandissue
againstthe table TOY.
---Checkingtheaudittable.
SQL> conn / as sysdba
Connected.
SQL> select* from dba_fga_audit_trail;
no rowsselected
-- as we can see dba_fga_audit_trail table doesnotcontainanyauditrecord
-- Nowbelowsql querywill hitthe auditconditions,that will save audit recordinthe table
dba_fga_audit_trial, letshavea look.
SQL> conn jiya/jiya
Connected.
SQL> select* from zoe.toy; --- 1st
Query issue by jiya
TOYNONAME COST MANF
---------- -------------------- ----------
3 charger 1500 dodge
4 plymounth 1200 plymounth
5 landcruser 2000 toyota
6 audi ax 1400 audi
7 mustang 2200 ford
12. ZOE
TOY
EXPENSIVE_CARS
select * from zoe.toy where cost>1600 --3rd query audited
09-APR-15 SASHA
oracle
ZOE
TOY
EXPENSIVE_CARS
select * from zoe.toy where cost>1800 --4th query aduited
09-APR-15 SASHA
oracle
ZOE
TOY
EXPENSIVE_CARS
select name, manf from zoe.toy where cost> 1700 --5th query audited