開啟/檢視 sql trace
1.設定event開啟
<== 重啟/連線斷開後失效,當然,如果是設定event引數,那重啟後肯定還保持
alter session set events '10046 trace name context forever,level 8';
oradebug session_event 10046 trace name context forever, level 12;
alter system set events '10046 trace name context forever,level 8';
SQL> oradebug setospid 20055
Oracle pid: 22, Unix process pid: 20055, image: oracle@zhangqiaoc (TNS V1-V3)
SQL> oradebug eventdump session
10046 trace name CONTEXT level 8, forever
SQL> oradebug eventdump system
10046 trace name CONTEXT level 8, forever
2.通過sql_trace開啟
<== 重啟/連線斷開後失效,當然,如果把引數寫入了spfile,那重啟後肯定還保持
alter session set sql_trace=true;
exec dbms_system.set_bool_param_in_session(148,52,'sql_trace',true);
SQL> oradebug setospid 20096;
Oracle pid: 18, Unix process pid: 20096, image: oracle@zhangqiaoc (TNS V1-V3)
SQL> oradebug DUMP MODIFIED_PARAMETERS 0
Statement processed.
<== trace檔案中
*** 2014-03-11 14:45:43.959
Received ORADEBUG command 'DUMP MODIFIED_PARAMETERS 0' from process Unix process pid: 20101, image:
DYNAMICALLY MODIFIED PARAMETERS:
sql_trace = TRUE
3.dbms包設定
<== 會話級別是斷開就失效,但是其他級別,是一直生效,直到手工關閉
exec dbms_support.start_trace_in_session(148,52,true,true);
exec dbms_support.start_trace(true,true); <== 開啟自己
exec dbms_system.set_sql_trace_in_session(148,52,true);
exec dbms_system.set_ev( 148,52,10046,12,'');
exec dbms_monitor.session_trace_enable(148,52,true,true);
exec dbms_monitor.serv_mod_act_trace_enable(service_name,module_name,action_name,true,true,instance_name);
exec dbms_monitor.client_id_trace_enable(client_id,true,true);
exec dbms_monitor.database_trace_enable(true,true,instance_name)
SQL> select sid,SQL_TRACE from v$session where sql_trace='ENABLED';
SID SQL_TRAC
---------- --------
148 ENABLED
SQL> select * from DBA_ENABLED_TRACES;
TRACE_TYPE
---------------------
PRIMARY_ID
----------------------------------------------------------------
QUALIFIER_ID1
------------------------------------------------
QUALIFIER_ID2 WAITS BINDS INSTANCE_NAME
-------------------------------- ----- ----- ----------------
DATABASE
TRUE FALSE
SQL> select * from wri$_tracing_enabled;
TRACE_TYPE PRIMARY_ID
---------- ----------------------------------------------------------------
QUALIFIER_ID1
------------------------------------------------
QUALIFIER_ID2 INSTANCE_NAME FLAGS
-------------------------------- ---------------- ----------
4 hrdb
w3wp.exe
8
4 hrdb
WorkflowService.exe
8
關閉sql trace,最好是用其對應的方法,或者是同一個類別的方法。否則可能存在無法關閉的現象
<== 重啟/連線斷開後失效,當然,如果是設定event引數,那重啟後肯定還保持
alter session set events '10046 trace name context forever,level 8';
oradebug session_event 10046 trace name context forever, level 12;
alter system set events '10046 trace name context forever,level 8';
SQL> oradebug setospid 20055
Oracle pid: 22, Unix process pid: 20055, image: oracle@zhangqiaoc (TNS V1-V3)
SQL> oradebug eventdump session
10046 trace name CONTEXT level 8, forever
SQL> oradebug eventdump system
10046 trace name CONTEXT level 8, forever
2.通過sql_trace開啟
<== 重啟/連線斷開後失效,當然,如果把引數寫入了spfile,那重啟後肯定還保持
alter session set sql_trace=true;
exec dbms_system.set_bool_param_in_session(148,52,'sql_trace',true);
SQL> oradebug setospid 20096;
Oracle pid: 18, Unix process pid: 20096, image: oracle@zhangqiaoc (TNS V1-V3)
SQL> oradebug DUMP MODIFIED_PARAMETERS 0
Statement processed.
<== trace檔案中
*** 2014-03-11 14:45:43.959
Received ORADEBUG command 'DUMP MODIFIED_PARAMETERS 0' from process Unix process pid: 20101, image:
DYNAMICALLY MODIFIED PARAMETERS:
sql_trace = TRUE
3.dbms包設定
<== 會話級別是斷開就失效,但是其他級別,是一直生效,直到手工關閉
exec dbms_support.start_trace_in_session(148,52,true,true);
exec dbms_support.start_trace(true,true); <== 開啟自己
exec dbms_system.set_sql_trace_in_session(148,52,true);
exec dbms_system.set_ev( 148,52,10046,12,'');
exec dbms_monitor.session_trace_enable(148,52,true,true);
exec dbms_monitor.serv_mod_act_trace_enable(service_name,module_name,action_name,true,true,instance_name);
exec dbms_monitor.client_id_trace_enable(client_id,true,true);
exec dbms_monitor.database_trace_enable(true,true,instance_name)
SQL> select sid,SQL_TRACE from v$session where sql_trace='ENABLED';
SID SQL_TRAC
---------- --------
148 ENABLED
SQL> select * from DBA_ENABLED_TRACES;
TRACE_TYPE
---------------------
PRIMARY_ID
----------------------------------------------------------------
QUALIFIER_ID1
------------------------------------------------
QUALIFIER_ID2 WAITS BINDS INSTANCE_NAME
-------------------------------- ----- ----- ----------------
DATABASE
TRUE FALSE
SQL> select * from wri$_tracing_enabled;
TRACE_TYPE PRIMARY_ID
---------- ----------------------------------------------------------------
QUALIFIER_ID1
------------------------------------------------
QUALIFIER_ID2 INSTANCE_NAME FLAGS
-------------------------------- ---------------- ----------
4 hrdb
w3wp.exe
8
4 hrdb
WorkflowService.exe
8
關閉sql trace,最好是用其對應的方法,或者是同一個類別的方法。否則可能存在無法關閉的現象
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8242091/viewspace-1107799/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- SQL TraceSQL
- Oracle 10046 SQL TRACEOracleSQL
- 一個快速檢視trace的小指令碼指令碼
- sql-server檢視SQLServer
- win10圖片檢視器在哪裡開啟 window10如何開啟照片檢視器Win10
- 如何檢視遠端埠是否開啟
- sql_trace相關指令碼SQL指令碼
- Oracle診斷案例-Sql_traceOracleSQL
- 【SQL】17 SQL 檢視(Views)、SQL Date 函式、SQL NULL 值、SQLView函式Null
- Oracle檢視歷史TOP SQLOracleSQL
- 控制檯實時檢視 sqlSQL
- linux檢視是否開啟超執行緒Linux執行緒
- Linux中如何檢視開啟了哪些埠?Linux
- Jtti:linux怎麼檢視swap是否開啟JttiLinux
- 單個SQL語句的10046 traceSQL
- windows10圖片檢視器怎麼開啟照片_win10圖片檢視器開啟照片的方法WindowsWin10
- sql大資料 基礎(檢視)SQL大資料
- ASP.NET Core 5.0 MVC中的檢視分類——佈局檢視、啟動檢視、具體檢視、分部檢視ASP.NETMVC
- win10怎麼檢視虛擬化是否開啟_檢視win10電腦是否開啟虛擬化的方法Win10
- Vs2013 .net framework開啟檢視原始碼方法Framework原始碼
- 檢視sqlserver的某程式的sql文字SQLServer
- 【學習】SQL基礎-015-檢視SQL
- 如何檢視SQL的執行計劃SQL
- [20220323]完善tpt get_trace.sql指令碼.txtSQL指令碼
- laravel開啟sql列印LaravelSQL
- 檢視程序的啟動命令
- heic用什麼軟體開啟,怎麼檢視heic
- SQL Server 檢視錶佔用空間大小SQLServer
- CentOS7檢視開放埠命令、檢視埠占用情況和開啟埠命令、殺掉程式等命令教程。CentOS
- win10任務檢視快捷鍵是什麼 開啟win10任務檢視的方法Win10
- centos7怎麼檢視、開啟和關閉防火牆CentOS防火牆
- CentOS8中開機啟動檢視管理的命令chkconfigCentOS
- linux版安全狗關閉 開啟 檢視 解除安裝命令Linux
- 使用SQL_TRACE進行資料庫診斷(轉)SQL資料庫
- MySQL_通過binlog檢視原始SQL語句MySql
- 如何使用SQL查詢檢視,Postico使用技巧分享~SQL
- SQL Server檢視所有表大小,所佔空間SQLServer
- 【SQL】Oracle查詢轉換之檢視合併SQLOracle
- win10怎麼檢視最近修改的檔案_win10如何檢視最近開啟的檔案Win10