ITPub博客

首页 > Linux操作系统 > Linux操作系统 > DBA Scripts:获得跟踪文件名称的gettrcname.sql[ 转自eygle博客]

DBA Scripts:获得跟踪文件名称的gettrcname.sql[ 转自eygle博客]

原创 Linux操作系统 作者:lorikyo 时间:2019-05-03 10:06:05 0 删除 编辑

其内容如下:
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
/

在Linux下执行该脚本输入类似:

SQL> @gettrcname

TRACE_FILE_NAME
---------------------------------------------------------------------------------------------------
/opt/oracle/admin/eygle/udump/eygle_ora_8415.trc

如我们执行一个跟踪操作:

SQL> alter session set sql_trace=true;

Session altered.

SQL> select count(*) from dba_users;

COUNT(*)
----------
9

SQL> ! head /opt/oracle/admin/eygle/udump/eygle_ora_8415.trc
/opt/oracle/admin/eygle/udump/eygle_ora_8415.trc
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production
ORACLE_HOME = /opt/oracle/product/9.2.0
System name: Linux
Node name: jumper.hurray.com.cn
Release: 2.4.21-15.EL
Version: #1 Thu Apr 22 00:27:41 EDT 2004
Machine: i686

收录一下blue_prince提供的更简化的脚本:
SELECT    a.VALUE
       || b.symbol
       || c.instance_name
       || '_ora_'
       || d.spid
       || '.trc' trace_file
  FROM (SELECT VALUE
          FROM v$parameter
         WHERE NAME = 'user_dump_dest') a,
       (SELECT SUBSTR (VALUE, -6, 1) symbol
          FROM v$parameter
         WHERE NAME = 'user_dump_dest') b,
       (SELECT instance_name
          FROM v$instance) c,
       (SELECT spid
          FROM v$session s, v$process p, v$mystat m
         WHERE s.paddr = p.addr AND s.SID = m.SID AND m.statistic# = 0) d
/

作者:eygle | English Version 【转载时请以超链接形式标明文章和作者信息及本声明

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/92530/viewspace-515880/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2004-07-18

  • 博文量
    211
  • 访问量
    155505