如何查看自己生成的tracle文件

来源:互联网 发布:poc软件对讲 编辑:程序博客网 时间:2024/05/16 04:57
1、查看udump的目录
$ sqlplus / as sysdba
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
license_max_users                    integer     0
parallel_adaptive_multi_user         boolean     TRUE
redo_transport_user                  string
user_dump_dest                       string      /u01/app/diag/rdbms/hxy/hxy/trace
SQL> 
SQL> select * from v$version;


BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE    11.2.0.1.0      Production
TNS for Linux: Version 11.2.0.1.0 - Production

NLSRTL Version 11.2.0.1.0 - Production


alter session set sql_ture=false;
方法一:
cd /u01/app/diag/rdbms/hxy/hxy/trace
格式化跟踪文件

[oracle@haoxy trace]$ tkprof hxy_ora_4256.trc ri.trc

TKPROF: Release 11.2.0.1.0 - Development on Tue Oct 15 07:00:34 2013


Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.


[oracle@haoxy trace]$ more  ri.trc 


TKPROF: Release 11.2.0.1.0 - Development on Tue Oct 15 07:00:34 2013


Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reser
ved.


Trace file: hxy_ora_4256.trc
Sort options: default


*************************************************************************
*******
count    = number of times OCI procedure was executed
cpu      = cpu time in seconds executing 
elapsed  = elapsed time in seconds executing
disk     = number of physical reads of buffers from disk
query    = number of buffers gotten for consistent read
current  = number of buffers gotten in current mode (usually for update)
rows     = number of rows processed by the fetch or execute call
*************************************************************************
*******
Trace file: hxy_ora_4256.trc
Trace file compatibility: 11.1.0.7
Sort options: default


       1  session in tracefile.
       0  user  SQL statements in trace file.
       0  internal SQL statements in trace file.
       0  SQL statements in trace file.
       0  unique SQL statements in trace file.
      84  lines in trace file.
       0  elapsed seconds in trace file.

方法二:
alter session set tracefile_identifier='haoxy';
alter session set sql_trace=ture;
select * from t
alter session set sql_ture=false;
tkprof  hxy_ora_haoxy.trc
方法三:
首先查看sid
desc v$mystat
select sid from v$mystat where rownum<2;
select spid from v$process where addr=(select paddr from v$session where sid =159);
2577
alter session set sql_trace=ture;
select * from t
alter session set sql_ture=false;
tkprof hxy_ora_4256.trc


查看跟踪文件位置

SQL> show parameter user_


NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
license_max_users                    integer     0

user_dump_dest                       string      /u01/app/diag/rdbms/hxy/hxy/trace

查看当前跟踪文件所存放在的文件名称

SQL> select value from v$diag_info where name='Default Trace File';


VALUE
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/u01/app/diag/rdbms/hxy/hxy/trace/hxy_ora_4051.trc


查看跟踪文件的一些工具有待进一步研究

[oracle@haoxy trace]$ tr
tr           traceroute6  trcasst      trcsess      
tracepath    tracert      trcldr       tree         
tracepath6   transx       trcroute     troff        
traceroute   trap         trcroute0    true    

[oracle@haoxy trace]$ trcsess

trcsess [output=<output file name >]  [session=<session ID>] [clientid=<clientid>] [service=<service name>] [action=<action name>] [module=<module name>] <trace file names>


output=<output file name> output destination default being standard output.
session=<session Id> session to be traced.
Session id is a combination of session Index & session serial number e.g. 8.13. 
clientid=<clientid> clientid to be traced.
service=<service name> service to be traced.
action=<action name> action to be traced.
module=<module name> module to be traced.
<trace_file_names> Space separated list of trace files with wild card '*' supported. 

其中output=  输出目的地默认值(作为标准输出)

session=  跟踪的会话(SID和SERIAL#)

clientid= 跟踪的客户端ID

service=  跟踪的服务

action=  跟踪的操作

module=  跟踪的模块

trace_file=  以空格分隔的跟踪文件名的列表,trcsess命令需要搜索该列表。如果没有列出任何文件,则搜索当前目录中的所有文件。在文件名中可以使用通配符*。