Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
oracle_audit_tracing [2019/08/09 13:31] – created andonovj | oracle_audit_tracing [2020/03/05 15:26] (current) – andonovj | ||
---|---|---|---|
Line 6: | Line 6: | ||
* OS = Audit Information is stored on the OS (Audit_dump_location) | * OS = Audit Information is stored on the OS (Audit_dump_location) | ||
* XML = Writes to the operating system audit record file in XML format. Prints all elements of the AuditRecord node | * XML = Writes to the operating system audit record file in XML format. Prints all elements of the AuditRecord node | ||
+ | * *EXTENDED = Addition to (DB and XML) Provides further audit data | ||
Line 13: | Line 14: | ||
=====Tracing===== | =====Tracing===== | ||
+ | Tracing can be enabled for: | ||
+ | |||
+ | * Current Session | ||
+ | * Specific Session | ||
+ | * Upon login | ||
+ | * Specific Service | ||
+ | * Specific OS Process | ||
+ | |||
+ | ====Current Session==== | ||
+ | <sxh bash> | ||
+ | -- Oracle 10g+ | ||
+ | SQL> EXEC DBMS_MONITOR.session_trace_enable; | ||
+ | SQL> EXEC DBMS_MONITOR.session_trace_enable(waits=> | ||
+ | SQL> EXEC DBMS_MONITOR.session_trace_disable; | ||
+ | |||
+ | -- All versions | ||
+ | SQL> ALTER SESSION SET sql_trace=TRUE; | ||
+ | SQL> ALTER SESSION SET sql_trace=FALSE; | ||
+ | |||
+ | SQL> EXEC DBMS_SESSION.set_sql_trace(sql_trace => TRUE); | ||
+ | SQL> EXEC DBMS_SESSION.set_sql_trace(sql_trace => FALSE); | ||
+ | |||
+ | SQL> ALTER SESSION SET EVENTS '10046 trace name context forever, level 8'; | ||
+ | SQL> ALTER SESSION SET EVENTS '10046 trace name context off'; | ||
+ | |||
+ | SQL> ORADEBUG EVENT 10046 TRACE NAME CONTEXT FOREVER, LEVEL 12; | ||
+ | SQL> ORADEBUG TRACEFILE_NAME; | ||
+ | SQL> ORADEBUG EVENT 10046 TRACE NAME CONTEXT OFF; | ||
+ | |||
+ | -- All versions, requires DBMS_SUPPORT package to be loaded. | ||
+ | SQL> EXEC DBMS_SUPPORT.start_trace(waits=> | ||
+ | SQL> EXEC DBMS_SUPPORT.stop_trace; | ||
+ | </ | ||
+ | |||
+ | ====Specific Session==== | ||
+ | <sxh bash> | ||
+ | -- Oracle 10g+ | ||
+ | SQL> EXEC DBMS_MONITOR.session_trace_enable(session_id=> | ||
+ | SQL> EXEC DBMS_MONITOR.session_trace_enable(session_id =>1234, serial_num=> | ||
+ | SQL> EXEC DBMS_MONITOR.session_trace_disable(session_id=> | ||
+ | |||
+ | -- All versions | ||
+ | SQL> EXEC DBMS_SYSTEM.set_ev(si=> | ||
+ | SQL> EXEC DBMS_SYSTEM.set_ev(si=> | ||
+ | |||
+ | -- With DBMS_SUPPORT | ||
+ | -- This. | ||
+ | @$ORACLE_HOME/ | ||
+ | |||
+ | -- Or this. | ||
+ | @?/ | ||
+ | |||
+ | SQL> EXEC DBMS_SUPPORT.start_trace_in_session(sid=> | ||
+ | SQL> EXEC DBMS_SUPPORT.stop_trace_in_session(sid=> | ||
+ | </ | ||
+ | |||
+ | |||
+ | ====Specific OS Process==== | ||
+ | <sxh bash> | ||
+ | -- Oracle 8i+ | ||
+ | SQL> ORADEBUG SETMYPID; | ||
+ | SQL> ORADEBUG SETOSPID 1234; -- Debug session with the specified OS process. | ||
+ | SQL> ORADEBUG SETORAPID 123456; | ||
+ | </ | ||
+ | |||
+ | ====Login==== | ||
Tracing can be enabled on LOGON via trigger as follows: | Tracing can be enabled on LOGON via trigger as follows: | ||
Line 42: | Line 109: | ||
end; | end; | ||
/ | / | ||
+ | </ | ||
+ | |||
+ | |||
+ | ====Specific Client==== | ||
+ | <sxh bash> | ||
+ | SQL> EXEC DBMS_MONITOR.client_id_trace_enable(client_id=>' | ||
+ | SQL> EXEC DBMS_MONITOR.client_id_trace_enable(client_id=>' | ||
+ | SQL> EXEC DBMS_MONITOR.client_id_trace_disable(client_id=>' | ||
+ | </ | ||
+ | |||
+ | ====Specific Object (e.g. Table)==== | ||
+ | <sxh bash> | ||
+ | 1. enable policy | ||
+ | begin | ||
+ | dbms_fga.add_policy ( | ||
+ | object_schema | ||
+ | object_name | ||
+ | policy_name | ||
+ | | ||
+ | statement_types | ||
+ | end; | ||
+ | / | ||
+ | 2. populate table: | ||
+ | | ||
+ | |||
+ | |||
+ | 3. drop policy | ||
+ | exec DBMS_FGA.DROP_POLICY (object_schema => ' | ||
+ | </ | ||
+ | |||
+ | You can of course choose to export to CSV using the following syntax on SQL: | ||
+ | |||
+ | <sxh bash> | ||
+ | set embedded on | ||
+ | set pagesize 0 | ||
+ | set colsep ';' | ||
+ | set echo off | ||
+ | set feedback off | ||
+ | set linesize 32767 | ||
+ | set trimspool on | ||
+ | set headsep off | ||
+ | spool name.csv | ||
</ | </ |