Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1406040
  • 博文数量: 556
  • 博客积分: 12626
  • 博客等级: 上将
  • 技术积分: 5799
  • 用 户 组: 普通用户
  • 注册时间: 2006-01-11 15:56
个人简介

从事IT基础架构多年,发现自己原来更合适去当老师……喜欢关注新鲜事物,不仅限于IT领域。

文章分类

全部博文(556)

文章存档

2019年(6)

2018年(15)

2017年(17)

2016年(11)

2015年(2)

2014年(2)

2013年(36)

2012年(54)

2011年(100)

2010年(41)

2009年(72)

2008年(14)

2007年(82)

2006年(104)

分类:

2006-09-30 22:41:50

    前面的文章里提到过dbms_system来跟踪session的方法,这篇文章讲的是怎么用oradebug来进行跟踪
 
How to Enable SQL_TRACE for Another Session Using ORADEBUG:
===========================================================

The ORADEBUG utility can enable/disable setting the SQL tracing for another
user's session.  To enable tracing for another session, the Oracle process
identifier (PID) or the Operating System processes identifier (SPID) must be
identified from v$process.  This is an effective way of capturing a SQL trace
from a process which is already running.  The output can be used to analyze
SQL related performance issues.

The ORADEBUG dump produces a trace file in the user_dump_dest that can be
formatted with TKPROF.  The ORADEBUG is a utility which is available from
Server Manager line mode (svrmgrl).  This utility is available in Oracle
versions 7.3 and up.
  
NOTE:  If using an older version of Oracle (prior to Oracle9), use 'svrmgrl'
instead of SQL*Plus as shown in the examples below.

e.g.
> svrmgrl
SVRMGR>  connect internal



Do the following: 

1. Obtain the Oracle process identifier or the Operating System process
   identifier (SPID) from v$process:

       >  sqlplus /nolog
       SQL> connect / as sysdba
       SQL> select pid, spid, username from v$process;

               PID    SPID   USERNAME
               ----   -----  --------
               8      25807  oracle
   

2. Attach to the process using ORADEBUG.

   Using the Oracle process identifier:

       SQL> oradebug setorapid 8

       Unix process pid: 25807, image: oracleV804


   - or - 
 

   Using the Operating System process identifier:

       SQL> oradebug setospid 25807

       Oracle pid: 8, Unix process pid: 25807, image: oracleV804
 

3. Turn on SQL Trace for the session.

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

       Statement processed.


4. Turn off the SQL trace for the session. 


       SQL> oradebug event 10046 trace name context off


5. Format trace file using TKPROF.


References: 
=========== 
 
   TKPROF and Problem Solving

 

总的来说,感觉oradebug更方便一些。



阅读(1963) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~