SQL>
ALTER SESSION SET EVENTS '10046 trace name context forever, level 12';
-- Execute the queries or operations to be traced here --
SQL>
ALTER SESSION SET EVENTS '10046 trace name context off';
OR
SQL> EXEC DBMS_MONITOR.session_trace_enable; (OR)
SQL>
EXEC DBMS_MONITOR.session_trace_enable(waits=>TRUE, binds=>FALSE);
-- Execute the queries or operations to be traced here --
SQL>
EXEC DBMS_MONITOR.session_trace_disable;
OR
SQL>
EXEC DBMS_SESSION.SESSION_TRACE_ENABLE(waits => TRUE, binds => FALSE);
-- Execute the queries or operations to be traced here --
SQL>
EXEC DBMS_SESSION.SESSION_TRACE_DISABLE();
OR
SQL>
EXEC DBMS_SESSION.set_sql_trace(sql_trace => TRUE);
-- Execute the queries or operations to be traced here --
SQL>
EXEC DBMS_SESSION.set_sql_trace(sql_trace => FALSE);
OR
SQL>
ALTER SESSION SET sql_trace=TRUE;
-- Execute the queries or operations to be traced here --
SQL>
ALTER SESSION SET sql_trace=FALSE;
OR
SQL>
EXEC DBMS_SUPPORT.start_trace(waits=>TRUE, binds=>FALSE);
-- Execute the queries or operations to be traced here --
SQL>
EXEC DBMS_SUPPORT.stop_trace;
Note: Need to install before use
SQL> connect / AS SYSDBA
SQL> @?\rdbms\admin\dbmssupp.sql
SQL> GRANT execute ON dbms_support TO schema_owner;
SQL> CREATE PUBLIC SYNONYM dbms_support FOR dbms_support;
-- Enable 10046 Trace on other's session
SQL>
EXEC DBMS_SYSTEM.set_ev(si=>123, se=>1234, ev=>10046, le=>12, nm=>' ');
-- Execute the queries or operations to be traced here --
SQL> EXEC DBMS_SYSTEM.set_ev(si=>123, se=>1234, ev=>10046, le=>0, nm=>' ');
OR
SQL> EXEC DBMS_MONITOR.session_trace_enable(session_id=>1234, serial_num=>1234); (OR)
SQL>
EXEC DBMS_MONITOR.session_trace_enable(session_id =>1234, serial_num=>1234, waits=>TRUE, binds=>FALSE);
-- Execute the queries or operations to be traced here --
SQL>
EXEC DBMS_MONITOR.session_trace_disable(session_id=>1234, serial_num=>1234);
OR
SQL>
EXEC DBMS_SYSTEM.set_sql_trace_in_session(sid=>123, serial#=>1234, sql_trace=>TRUE);
-- Execute the queries or operations to be traced here --
SQL>
EXEC DBMS_SYSTEM.set_sql_trace_in_session(sid=>123, serial#=>1234, sql_trace=>FALSE);
OR
SQL>
EXEC DBMS_SUPPORT.start_trace_in_session(sid=>123, serial=>1234, waits=>TRUE, binds=>FALSE);
-- Execute the queries or operations to be traced here --
SQL>
EXEC DBMS_SUPPORT.stop_trace_in_session(sid=>123, serial=>1234);
OR
Tracing a process after it has started. Please find out PID, SPID using below query
select p.PID,p.SPID,s.SID
from v$process p,v$session s
where s.paddr = p.addr
and s.sid = '&SESSION_ID'
/
SPID is the operating system Process identifier (os pid)
PID is the Oracle Process identifier (ora pid)
Using SPID (os pid)
connect / as sysdba
oradebug setospid 9834
oradebug unlimit
oradebug event 10046 trace name context forever,level 12
-- Execute the queries or operations to be traced here --
oradebug tracefile_name; -- display the current trace file.
oradebug event 10046 trace name context off
OR
using PID (ora pid)
connect / as sysdba
oradebug setorapid 9834
oradebug unlimit
oradebug event 10046 trace name context forever,level 12
-- Execute the queries or operations to be traced here --
oradebug tracefile_name;
-- display the current trace file.
oradebug event 10046 trace name context off