跟踪文件非常有助于我们分析问题
,跟踪文件的文件名可以用以下查询得到:
01 SELECT
02 d.VALUE
03 || '/'
04 || LOWER (RTRIM (i.INSTANCE, CHR (0)))
05 || '_ora_'
06 || p.spid
07 || '.trc' trace_name
08 FROM
09 (
10 SELECT
11 p.spid
12 FROM
13 v$mystat m, v$session s, v$process p
14 WHERE
15 m.statistic# = 1 AND s.SID = m.SID AND p.addr = s.paddr
16 ) p,
17 (
18 SELECT
19 t.INSTANCE
20 FROM
21 v$thread t, v$parameter v
22 WHERE
23 v.NAME = 'thread'
24 AND
25 ( v.VALUE = 0 OR t.thread# = TO_NUMBER (v.VALUE) )
26 ) i,
27 (
28 SELECT
29 VALUE
30 FROM v$parameter
31 WHERE NAME = 'user_dump_dest'
32 ) d;
1 TRACE_NAME
2 -----------------------------------------------------------------
3 /u01/app/oracle/diag/rdbms/logdw/logdw/trace/logdw_ora_8535.trc
但是每次都要默写如此常常的
SQL语句非常痛苦
,我们可以对其包装成函数,然后让public都可以执行:
01 create or replace function get_trace_name return varchar2 as
02 v_result varchar2(300);
03 begin
04 SELECT
05 d.VALUE
06 || '/'
07 || LOWER (RTRIM (i.INSTANCE, CHR (0)))
08 || '_ora_'
09 || p.spid
10 || '.trc' trace_name
11 INTO v_result
12 FROM
13 (
14 SELECT
15 p.spid
16 FROM
17 v$mystat m, v$session s, v$process p
18 WHERE
19 m.statistic# = 1 AND s.SID = m.SID AND p.addr = s.paddr
20 ) p,
21 (
22 SELECT
23 t.INSTANCE
24 FROM
25 v$thread t, v$parameter v
26 WHERE
27 v.NAME = 'thread'
28 AND
29 ( v.VALUE = 0 OR t.thread# = TO_NUMBER (v.VALUE) )
30 ) i,
31 (
32 SELECT