亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

ORACLE TRACE 10046事件常見的幾種方法

標簽:
Oracle


    下面是10046事件的几个等级分别表示什么意思

Level 0 Tracing is disabled. This is the same as setting SQL_TRACE = FALSE. 

 

Level 1 Standard SQL trace information (SQL_TRACE = TRUE). This is the default level. 

 

Level 4 SQL trace information plus bind variable values. 

 

Level 8 SQL trace information plus wait event information. 

 

Level 12 SQL trace information, wait event information, and bind variable values. 

   下面是常见的几种方法

一、trace当前进程

 

 

1,event方法 

alter session set timed_statistics = true; 

alter session set max_dump_file_size = unlimited; 

alter session set events '10046 trace name context forever, level 8'; 

alter session set events '10046 trace name context off';     

 

2,dbms_support方法 

alter session set timed_statistics = true; 

alter session set max_dump_file_size = unlimited; 

exec sys.dbms_support.start_trace; 

--To include Bind variable values, Wait Event data with SQL trace 

exec sys.dbms_support.start_trace(waits => TRUE, binds=> TRUE) 

exec sys.dbms_support.stop_trace; 

 

3,oradebug 方法 

alter system set timed_statistics = true; 

SQL> oradebug setmypid 

Statement processed. 

SQL> oradebug unlimit; 

Statement processed. 

SQL> oradebug event 10046 trace name context forever,level 8 

Statement processed. 

二,trace其它进程

  在trace其它进程前,先修改下面两个参数的值 -- Set TIME_STATISTICS to TRUE for SID 10, Serial# 118 

exec sys.dbms_system.set_bool_param_in_session(- 

sid => 10, - 

serial# => 118, - 

parnam => 'TIMED_STATISTICS',- 

bval => true); 

-- Set MAX_DUMP_FILE_SIZE to 2147483647 

-- for SID 10, Serial# 118 

exec sys.dbms_system.set_int_param_in_session(- 

sid => 10,- 

serial# => 118,- 

parnam => 'MAX_DUMP_FILE_SIZE',- 

intval => 2147483647); 

 

 

1,使用dbms_support方法 

 

-- Enable ‘level 12’ trace in session 10 with serial# 118 

exec dbms_support.start_trace_in_session(- 

sid => 10,- 

serial => 118,- 

waits => true,- 

binds => true); 

-- Let the session execute SQL script or -- program for some amount of time  

-- To turn off the tracing: 

exec dbms_support.stop_trace_in_session(- 

sid => 10, - 

serial => 118); 

 

2,使用DBMS_SYSTEM  

-- Enable trace at level 8 for session 10 with serial# 118 

exec dbms_system.set_ev( 10, 118, 10046, 8, '');   

-- Let the session execute SQL script or-- program for some amount of time  

-- To turn off the tracing: 

exec dbms_system.set_ev( 10, 118, 10046, 0, ''); 

 

3,使用oradebug工具 

在使用oradebug工具前,我们得先查找到sess在操作系统上面的进程号,可以使用下面的SQL来查询 

select s.username,p.spid os_process_id,p.pid oracle_process_id from   v$session s, v$process p where  s.paddr = p.addr and s.sid=&sid; 

 

查看进程号后,使用下面的命令 

alter system set timed_statistics = true; 

oradebug setospid 6509;   

-- 6509 is the OS process id for the session 

oradebug unlimit; 

oradebug event 10046 trace name context forever, level 8; 

-- Let the session execute SQL script  

-- or program for some amount of time  

-- To turn off the tracing: 

oradebug event 10046 trace name context off; 

4,使用dbms_monitor 

exec dbms_monitor.session_trace_enable( -      

session_id => 10,-      

serial_num => 118, -      

waits => true, -      

binds => true); 

-- Let the session execute SQL script or -- program for some amount of time  

-- To turn off the tracing: 

exec dbms_monitor.session_trace_disable( -      

session_id => 10, -      

serial_num => 118);  

 

©著作权归作者所有:来自51CTO博客作者7343696的原创作品,如需转载,请注明出处,否则将追究法律责任

traceoradebugORACLE 基础


點擊查看更多內容
TA 點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優質文章

正在加載中
  • 推薦
  • 評論
  • 收藏
  • 共同學習,寫下你的評論
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

舉報

0/150
提交
取消