下面的脚本执行后返回当前会话的trace文件:
select
u_dump.value || '/' ||
db_name.value || '_ora_' ||
v$process.spid ||
nvl2(v$process.traceid, '_' || v$process.traceid, null )
|| '.trc' "Trace File"
from
v$parameter u_dump
cross join v$parameter db_name
cross join v$process
join v$session
on v$process.addr = v$session.paddr
where
u_dump.name = 'user_dump_dest' and
db_name.name = 'db_name' and
v$session.audsid=sys_context('userenv','sessionid');
C.VALUE||'/'||'ORA_'||LTRIM(TO_CHAR(A.SPID,'FM99999'))||'.TRC'
--------------------------------------------------------------------------------
/u01/oracle/app/admin/som/udump/ora_22025.trc
除此之外还有其他两种方法,使我们更简单的找到trace文件:
方法一:
通过会话级设置tracefile_identifier参数:
alter session set tracefile_identifier = my_session_tracefile;
然后执行dump命令,这样我们可以在udump目录下看到一个含有MY_SESSION_TRACEFILE的文件。
方法二:
通过oradubug命令找到trace文件,如下:
SQL> oradebug setmypid
Statement processed.
SQL> alter system dump datafile 1 block 61618;
System altered.
SQL> oradebug tracefile_name
/u01/oracle/app/admin/som/udump/som_ora_22074.trc
11g 得到跟踪文件方法:
--方法1 11g:
SQL> select * from v$diag_info where name='Default Trace File';
--方法2 11g:
SQL> select spid,tracefile from V$process where addr in(select paddr from v$session where sid=sys_context('userenv','sid'));
--方法3:11g
SQL> oradebug setmypid
SQL> oradebug tracefile_name
--方法4:11g老方法
-------------a------------
SQL> select d.value
||'/'
||lower(rtrim(i.instance,chr(0)))
||'_ora_'
||p.spid
||'.trc' trace_file_name
from (select p.spid
from v$mystat m,v$session s,v$process p
where m.statistic#=1 and s.sid=m.sid and p.addr=s.paddr) p,
(select t.instance from v$thread t,v$parameter v
where v.name='thread' and (v.value=0 or t.thread#=to_number(v.value))) i,
(select value from v$parameter where name='user_dump_dest') d;
-------------b------------
SQL> select
u_dump.value || '/' ||
db_name.value || '_ora_' ||
v$process.spid ||
nvl2(v$process.traceid, '_' || v$process.traceid, null )
|| '.trc' "Trace File"
from
v$parameter u_dump
cross join v$parameter db_name
cross join v$process
join v$session
on v$process.addr = v$session.paddr
where
u_dump.name = 'user_dump_dest' and
db_name.name = 'db_name' and
v$session.audsid=sys_context('userenv','sessionid');
From:http://www.oraclett.com/oracle_base/20111016/166.html