打对了

实践Oracle优化技术在医疗信息化中的深入应用,探索医院信息系统性能优化设计之道。公众号:医信系统性能优化。

 

在客户端通过外部表访问Trace文件的内容

有时候,因为服务器的权限原因,或者因为异构操作系统等因素,我们无法及时获取Trace文件,下面这种方法通过SQL查询读出Trace文件的内容。

 

1。先查出Trace文件的名称及目录;

2。建立目录对象;

3。创建外部表;

4。查询外部表;代码

Select d.Value || '\' || Lower(RTrim(i.Instance, Chr(0))) || '_ora_' || p.Spid || '.trc' Trace_File_Name
From (Select p.Spid
       
From Sys.V$mystat M, Sys.V$session S, Sys.V$process P
       
Where m.Statistic# = 1 And s.Sid = m.Sid And p.Addr = s.Paddr) P,
     (
Select t.Instance
       
From Sys.V$thread T, Sys.V$parameter V
       
Where v.Name = 'thread' And (v.Value = 0 Or t.Thread# = To_Number(v.Value))) I,
     (
Select Value From Sys.V$parameter Where Name = 'user_dump_dest') D

create directory tracefile as 'G:\ORACLE\PRODUCT\10.2.0\DB_1\ADMIN\ORCL\UDUMP';
create table tracefile 
 (
TEXT varchar2(4000))
 organization external (
 type oracle_loader
 
default directory tracefile
 access parameters (
 records delimited 
by newline
 nobadfile
 nodiscardfile
 nologfile 
 )
 location(
'orcl_ora_4800.trc')
 ) reject limit Unlimited;
 
 
select * from tracefile;

 

posted on 2010-05-06 09:26  知道得越多知道的越少  阅读(346)  评论(0编辑  收藏  举报

导航