Get SID :
================
column SID for a20
SELECT sys_context('USERENV', 'SID') SID FROM DUAL;
Enable Trace for SID in oracle
==================================
SQL> select username,sid,serial# from v$session where sid=22;
USERNAME SID SERIAL#
------------------------------ ---------- ----------
SYS 22 2895
SQL>
alter session set tracefile_identifier='anurag_sql_trace';
SQL> EXEC DBMS_SYSTEM.set_sql_trace_in_session(sid=>22, serial#=>2895, sql_trace=>TRUE)
---To disable
SQL> EXEC DBMS_SYSTEM.set_sql_trace_in_session(sid=>123, serial#=>1234, sql_trace=>FALSE);
--- Get the tracefile name:
SELECT p.tracefile FROM v$session s JOIN v$process p ON s.paddr = p.addr WHERE s.sid = 22;
TRACEFILE
------------------------------------------------------------------
/u01/app/oracle/diag/rdbms/db11g/db11g/trace/db11g_ora_9699.trc
No comments:
Post a Comment