原 Oracle 获取trace跟踪文件名的几种常用方式
获取trace跟踪文件名的几种方式
跟踪文件(trace file)一般位于“user_dump_dest”参数所指定的目录中,位置及文件名可以通过以下SQL查询获得。
通过user_dump_dest查询
运行如下SQL来创建视图:
1 2 3 4 5 6 7 8 9 10 11 12 13 | CREATE OR REPLACE VIEW VW_SQL_TRACE_NAME_LHR AS 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 TO_CHAR(T.THREAD#) = V.VALUE)) I, (SELECT VALUE FROM V$PARAMETER WHERE NAME = 'user_dump_dest') D; |
创建公共同义词:
1 2 3 4 5 6 | CREATE OR REPLACE PUBLIC SYNONYM SYN_TRACENAME_LHR FOR VW_SQL_TRACE_NAME_LHR; SYS@lhrdb> select * from VW_SQL_TRACE_NAME_LHR; TRACE_FILE_NAME -------------------------------------------------------------------------------- /oracle/app/oracle/diag/rdbms/lhrdb/lhrdb/trace/lhrdb_ora_19660944.trc |