Use of oradebug (practical part) (in continuous update)

Time:2020-2-13

Trace a session

For example, if I want to track a session, I need to obtain the SID, serial ID, and SPID of the session first

SELECT a.username,
  a.sid ,
  a.serial#,
  b.spid
FROM v$session a,
  v$process b
WHERE a.paddr=b.addr
and a.sid = 285
;

USERNAME                              SID    SERIAL# SPID
------------------------------ ---------- ---------- ------------------------
APPS                                  285      44645 30468

Then use oradebug to set the event on the target session, trace, and get the name of trace file

SQL > oradebug setospid 30468 -- process SPID

SQL> oradebug event 10046 trace name context forever,level 12

SQL> oradebug event 10046 trace name context off

SQL> oradebug TRACEFILE_NAME

/u01/VIS02/db/tech_st/11.1.0/admin/VIS02_vs011/diag/rdbms/vis02/VIS02/trace/VIS02_ora_30468.trc