oracle 10046详解,ORACLE TRACE 10046事件常见的几种方法

下面是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 基础

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值