欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

Oracle 11g中定位trace文件简便办法

程序员文章站 2024-01-06 22:50:28
...

在Oracle11g当中,可以有更加简单的定位当前trace文件的办法,那就是访问视图 v$diag_info。 store@TESTgt; select * from v$ve

在Oracle11g当中,可以有更加简单的定位当前trace文件的办法,那就是访问视图 v$diag_info。
store@TEST> 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
store@TEST> set linesize 1500;
store@TEST> SELECT * FROM v$diag_info;

INST_ID NAME VALUE
---------- ---------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 Diag Enabled TRUE
1 ADR Base /opt/oracle/db
1 ADR Home /opt/oracle/db/diag/rdbms/test/TEST
1 Diag Trace /opt/oracle/db/diag/rdbms/test/TEST/trace
1 Diag Alert /opt/oracle/db/diag/rdbms/test/TEST/alert
1 Diag Incident /opt/oracle/db/diag/rdbms/test/TEST/incident
1 Diag Cdump /opt/oracle/db/diag/rdbms/test/TEST/cdump
1 Health Monitor /opt/oracle/db/diag/rdbms/test/TEST/hm
1 Default Trace File /opt/oracle/db/diag/rdbms/test/TEST/trace/TEST_ora_5555.trc
1 Active Problem Count 0
1 Active Incident Count 0

已选择11行。
视图中name='Default Trace File'的记录就是当前session的默认trace file。
store@TEST> SELECT value FROM v$diag_info WHERE;

VALUE
----------------------------------------------------------------------------------------------------
/opt/oracle/db/diag/rdbms/test/TEST/trace/TEST_ora_5555.trc

store@TEST> alter system set sql_trace=true;

系统已更改。

store@TEST> select * from dual;

D
-
X

store@TEST> alter system set sql_trace=false;

系统已更改。

store@TEST> !cat /opt/oracle/db/diag/rdbms/test/TEST/trace/TEST_ora_5555.trc
Trace file /opt/oracle/db/diag/rdbms/test/TEST/trace/TEST_ora_5555.trc
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORACLE_HOME = /opt/oracle/db/db_1
System name: Linux
Node name: gtlions
Release: 2.6.18-194.el5PAE
Version: #1 SMP Mon Mar 29 20:19:03 EDT 2010
.。。。。
。。。。。
PARSING IN CURSOR #9 len=18 dep=0 uid=93 oct=3 lid=93 tim=1295493303679484 hv=942515969 ad='3a0de6c0' sqlid='a5ks9fhw2v9s1'
select * from dual
END OF STMT
PARSE #9:c=14999,e=158076,p=0,cr=3,cu=0,mis=1,r=0,dep=0,og=1,plh=272002086,tim=1295493303679479
.。。。
。。。。
=====================
PARSING IN CURSOR #7 len=32 dep=0 uid=93 oct=49 lid=93 tim=1295493315875782 hv=3586475918 ad='0' sqlid='19zugf7awajwf'
alter system set sql_trace=false
END OF STMT
PARSE #7:c=0,e=1849,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=0,plh=0,tim=1295493315875778
EXEC #7:c=9999,e=14897,p=0,cr=0,cu=3,mis=0,r=0,dep=0,og=0,plh=0,tim=1295493315891023

小结
关键词: v$diag_info,sql_trace
-The End-

Oracle 11g中定位trace文件简便办法

上一篇:

下一篇: