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
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条评论
如果能找个例子分析下trace的结果还有根据trace结果从哪里入手调优sql可能会更好。呵呵
对第一个比较熟悉,下面的还不是很了解的,要继续努力了‘
呵呵,一般都是troubleshooting的时候采用trace,tuning一般用statspack。
这边有一个用trace进行分析的例子:
http://www.oracleblog.org/working-case/using-errorstack-to-solve-exp-problem/