trace的一些小结

1. 使用autotrace:
set autotrace ON | ON EXPLAIN | ON STATISTICS | TRACEONLY | TRACEONLY EXPLAIN
set autotrace off

2. 使用set events context :
alter session set events ‘10046 trace name context forever,level 12’;
alter session set events ‘10046 trace name context off’;

3. 使用set events immediate
alter session set events ‘immediate trace name library_cache|controlf|systemstate|processstate|file_hdrs|REDOHDR level 10’;
alter session set events ‘immediate trace name off’;

4. 使用set events errorstack
alter session set events ‘err_num trace name errorstack level 10’;
alter session set events ‘err_num trace name errorstack off’

5. 使用dbms_support(trace别的session):
exec dbms_support.start_trace_in_session(sid=>XX,seiral#=>XXX,wait=>true,binds=>true);
exec dbms_support.stop_trace_in_session(sid=>XX,seiral#=>XXX);

6. 使用oradebug(trace别的session):
oradebug setospid (PID 能从ps -ef 中得出)
oradebug unlimit
oradebug event 10046 trace name context forever,level 12;
oradebug event 10046 trace name context off;

7. 使用dbms_system.set_ev:
exec dbms_system.set_ev(sid,serial#,10046,trace_level,’username’);
exec dbms_system.set_ev(sid,serial#,10046,0,’username’);
ps:感谢小熊的补充

相关文章

3条评论

  1. 如果能找个例子分析下trace的结果还有根据trace结果从哪里入手调优sql可能会更好。呵呵

发表评论

电子邮件地址不会被公开。 必填项已用*标注