Enable trace 10046 in Oracle PL/SQL

SQL> ALTER SESSION SET EVENTS '10046 trace name context forever, level 8';

SQL> SQL STATEMENT GOES HERE

SQL> ALTER SESSION SET EVENTS '10046 trace name context off';


Tips:

1) Query the generated trace file.

SELECT s.sid,
       s.serial#,
       pa.value || '/' || LOWER(SYS_CONTEXT('userenv','instance_name')) ||    
       '_ora_' || p.spid || '.trc' AS trace_file
FROM   v$session s,
       v$process p,
       v$parameter pa
WHERE  pa.name = 'user_dump_dest'
AND    s.paddr = p.addr
AND    s.audsid = SYS_CONTEXT('USERENV', 'SESSIONID');

2) Include your preference in the trace file name (more easily identified)

ALTER SESSION SET TRACEFILE_IDENTIFIER = "MY_TEST_SESSION";

3) Analysis the trace file by using "tkprof" or "Trace Analyzer".


References:

http://www.oracle-base.com/articles/10g/sql-trace-10046-trcsess-and-tkprof-10g.php
http://www.petefinnigan.com/ramblings/how_to_set_trace.htm

你可能感兴趣的:(Enable trace 10046 in Oracle PL/SQL)