ORACLE TRACE 10046
trace 當前程式
方式一
ALTER SESSION SET SQL_TRACE = TRUE ;(exec sys.dbms_support.start_trace ;)
Alter session set events '?10046 trace name context forever, level 12';
--sql
Alter session set events '10046 trace name context off';
ALTER SESSION SET SQL_TRACE = FALSE;(exec sys.dbms_support.stop_trace ;)
方式二
oradebug setmypid xxxx
--sql
oradebug event 10046 trace name context forever, level 12;
oradebug event 10046 trace name context off ;
trace 其他程式
--select a.SID,a.SERIAL# from v$session a where a.SID=&sid
方式一
exec sys.dbms_system.SET_BOOL_PARAM_IN_SESSION(18, 226, 'sql_trace', TRUE);
exec dbms_system.set_ev(18, 226, 10046, 12, '');
--sql
exec dbms_system.set_ev(18, 226, 10046, 0, '');
exec sys.dbms_system.SET_BOOL_PARAM_IN_SESSION(18, 226, 'sql_trace', FALSE);
方式二
exec dbms_system.set_sql_trace_in_session(18,226,TRUE);
exec sys.dbms_monitor.session_trace_enable(session_id=>18,serial_num=>226, waits=>true, binds=>true);
--sql
exec sys.dbms_monitor.session_trace_disable(session_id=>18,serial_num=>226);
exec dbms_system.set_sql_trace_in_session(18,226,FALSE);
注意:以上兩種方式不支援對正在執行的sql進行trace
方式三(oradebug方式)
--select b.SPID from v$session a,v$process b where a.PADDR=b.ADDR and a.SID=&SID;
--獲取os程式id
oradebug setospid xxxx
oradebug event 10046 trace name context forever, level 12;
oradebug tracefile_name
oradebug event 10046 trace name context off ;
10046 EVENT 級別
These are bit values so can be ORed together to get different mixes
1 - Enable standard SQL_TRACE functionality (Default)
4 - As Level 1 PLUS trace bind values [ bind=true ]
8 - As Level 1 PLUS trace waits [ wait=true ]
This is especially useful for spotting latch wait etc.
but can also be used to spot full table scans and index scans.
As of 11g these additional bit levels are available:
16 - Generate STAT line dumps for each execution [ plan_stat=all_executions ]
32 - Never dump execution statistics [ plan_stat=never ]
As of 11.2.0.2 this additional bit level is available:
64 - Adaptive dump of STAT lines. [ plan_stat=adaptive ]
This dumps the STAT information if a SQL took more than about 1 minute thereby
giving information for the more expensive SQLs and for different executions of such
SQLs.
eg: A common event level is 12 which includes standard SQL_TRACE output, binds, waits and
default STAT line tracing.
Notes:
STAT dumping has been amended in 11g so that they are not aggregated across all executions but are
dumped after execution. This has been done to address cases where the cursor is not closed and the
STAT information is therefore not dumped. Now we guarantee to capture the STAT information
following the execution. See the above bit levels to have finer control over STAT lines.
10046輸出內容解釋參考
Interpreting Raw SQL_TRACE output (Doc ID 39817.1)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8494287/viewspace-1357467/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle 10046 SQL TRACEOracleSQL
- Oracle SQL Trace 和 10046 事件OracleSQL事件
- 讀懂Oracle 10046 SQL TRACEOracleSQL
- Oracle SQL Trace 和10046 事件OracleSQL事件
- oracle sql trace與10046淺談OracleSQL
- Maclean教你讀Oracle 10046 SQL TRACEMacOracleSQL
- How to read Oracle 10046 trace fileOracle
- Oracle 11g新SQL Trace 10046方法OracleSQL
- Oracle中開啟10046 Trace的各種方法Oracle
- 10046 trace詳解(1)
- sql_trace/ 10046 整理SQL
- sql_trace and 10046事件SQL事件
- Oracle中開啟10046 Trace的各種方法[轉]Oracle
- Event 10046 - Enable SQL Statement TraceSQL
- Oracle中開啟trace 10046 event 的各種方法[zt]Oracle
- ZT 自動10046 trace指令碼指令碼
- 單個SQL語句的10046 traceSQL
- sql_trace、10046、10053、tkprofSQL
- 如何使用SQL_TRACE和10046事件SQL事件
- 跟蹤SQL - SQL Trace 及 10046 事件SQL事件
- 利用10046事件收集SQL的trace檔案事件SQL
- SQL TRACE和TKPROF,10046的使用步驟SQL
- 拜年+散分貼《Oracle SQL_TRACE和10046事件優化SQL例項》OracleSQL事件優化
- oracle 10046Oracle
- how to start '10046 trace name context forever,level 12'Context
- 10046 跟蹤的trace檔案相關解釋
- 使用10046 ,10053 並讀懂 trace 檔案
- 使用10046 event trace跟蹤全表掃描操作
- 使用SQL_TRACE /10046進行資料庫診斷SQL資料庫
- How to Get a 10046 trace for a Parallel Query [ID 1102801.1]Parallel
- Oracle session traceOracleSession
- 如何收集用來診斷效能問題的10046 Trace(SQL_TRACE) (文件 ID 1523462.1)SQL
- 【TRACE】如果通過10046跟蹤資料庫效能問題資料庫
- 只對某個特定的SQL語句開啟10046 traceSQL
- 使用 oracle 10046 eventOracle
- Oracle sql trace用法OracleSQL
- How to enable trace in OracleOracle
- Oracle Trace 及TKPROFOracle