Scripts:找出后台trace文件的脚本sess_user_trace_file_location.sql
2014-06-03 09:38
387 查看
-- +----------------------------------------------------------------------------+
-- | Jeffrey M. Hunter |
-- | jhunter@idevelopment.info |
-- | www.idevelopment.info |
-- |----------------------------------------------------------------------------|
-- | Copyright (c) 1998-2012 Jeffrey M. Hunter. All rights reserved. |
-- |----------------------------------------------------------------------------|
-- | DATABASE : Oracle |
-- | FILE : sess_user_trace_file_location.sql |
-- | CLASS : Session Management |
-- | PURPOSE : Oracle writes TRACE to the directory based on the value of your |
-- | "user_dump_dest" parameter in init.ora file. The trace files |
-- | use the "System Process ID" as part of the file name to ensure |
-- | a unique file for each user session. The following query helps |
-- | the DBA to determine where the TRACE files will be written and |
-- | the name of the file it would create for its particular |
-- | session. |
-- | NOTE : As with any code, ensure to test this script in a development |
-- | environment before attempting to run it in production. |
-- +----------------------------------------------------------------------------+
SET TERMOUT OFF;
COLUMN current_instance NEW_VALUE current_instance NOPRINT;
SELECT rpad(instance_name, 17) current_instance FROM v$instance;
SET TERMOUT ON;
PROMPT
PROMPT +------------------------------------------------------------------------+
PROMPT | Report : User Session Trace File Location |
PROMPT | Instance : ¤t_instance |
PROMPT +------------------------------------------------------------------------+
SET ECHO OFF
SET FEEDBACK 6
SET HEADING ON
SET LINESIZE 180
SET PAGESIZE 50000
SET TERMOUT ON
SET TIMING OFF
SET TRIMOUT ON
SET TRIMSPOOL ON
SET VERIFY OFF
CLEAR COLUMNS
CLEAR BREAKS
CLEAR COMPUTES
COLUMN "Trace File Path" FORMAT a80 HEADING 'Your trace file with path is:'
SELECT
a.trace_path || ' > ' || b.trace_file "Trace File Path"
FROM
( SELECT value trace_path
FROM v$parameter
WHERE name='user_dump_dest'
) a
, ( SELECT c.instance || '_ora_' || spid ||'.trc' TRACE_FILE
FROM v$process,
(select lower(instance_name) instance from v$instance) c
WHERE addr = ( SELECT paddr
FROM v$session
WHERE (audsid, sid) = ( SELECT
sys_context('USERENV', 'SESSIONID')
, sys_context('USERENV', 'SID')
FROM dual
)
)
) b
/
-- | Jeffrey M. Hunter |
-- | jhunter@idevelopment.info |
-- | www.idevelopment.info |
-- |----------------------------------------------------------------------------|
-- | Copyright (c) 1998-2012 Jeffrey M. Hunter. All rights reserved. |
-- |----------------------------------------------------------------------------|
-- | DATABASE : Oracle |
-- | FILE : sess_user_trace_file_location.sql |
-- | CLASS : Session Management |
-- | PURPOSE : Oracle writes TRACE to the directory based on the value of your |
-- | "user_dump_dest" parameter in init.ora file. The trace files |
-- | use the "System Process ID" as part of the file name to ensure |
-- | a unique file for each user session. The following query helps |
-- | the DBA to determine where the TRACE files will be written and |
-- | the name of the file it would create for its particular |
-- | session. |
-- | NOTE : As with any code, ensure to test this script in a development |
-- | environment before attempting to run it in production. |
-- +----------------------------------------------------------------------------+
SET TERMOUT OFF;
COLUMN current_instance NEW_VALUE current_instance NOPRINT;
SELECT rpad(instance_name, 17) current_instance FROM v$instance;
SET TERMOUT ON;
PROMPT
PROMPT +------------------------------------------------------------------------+
PROMPT | Report : User Session Trace File Location |
PROMPT | Instance : ¤t_instance |
PROMPT +------------------------------------------------------------------------+
SET ECHO OFF
SET FEEDBACK 6
SET HEADING ON
SET LINESIZE 180
SET PAGESIZE 50000
SET TERMOUT ON
SET TIMING OFF
SET TRIMOUT ON
SET TRIMSPOOL ON
SET VERIFY OFF
CLEAR COLUMNS
CLEAR BREAKS
CLEAR COMPUTES
COLUMN "Trace File Path" FORMAT a80 HEADING 'Your trace file with path is:'
SELECT
a.trace_path || ' > ' || b.trace_file "Trace File Path"
FROM
( SELECT value trace_path
FROM v$parameter
WHERE name='user_dump_dest'
) a
, ( SELECT c.instance || '_ora_' || spid ||'.trc' TRACE_FILE
FROM v$process,
(select lower(instance_name) instance from v$instance) c
WHERE addr = ( SELECT paddr
FROM v$session
WHERE (audsid, sid) = ( SELECT
sys_context('USERENV', 'SESSIONID')
, sys_context('USERENV', 'SID')
FROM dual
)
)
) b
/
相关文章推荐
- Scripts:查询每个数据文件等待时间的脚本perf_file_waits.sql
- Scripts:报告所有用户session信息的脚本sess_user_sessions.sql
- Scripts:查询数据文件IO使用率的脚本 perf_file_io.sql
- Scripts:查看数据文件使用率的脚本(包括临时表空间的文件哦)dba_file_space_usage.sql
- Scripts:查询每个数据文件使用效率的脚本perf_file_io_efficiency.sql
- Scripts:报告数据库中数据文件控制文件临时文件redo文件的使用情况dba_file_use.sql
- Scripts:根据sql文本找出相应SQL信息的脚本find_sql.sql
- 获取隐含参数, 当前trace文件名称,sql语句的执行计划的脚本
- Scripts:此脚本慎用lob_fragmentation_user.sql
- Scripts:给出系统pid找出sql的脚本pid4sql.sql
- alter database backup controlfile to trace创建控制文件脚本,重建控制文件
- Scripts:找出使用最多buffer get的SQL脚本perf_top_sql_by_buffer_gets.sql
- Scripts:找出使用最高的10个表的脚本perf_top_10_tables.sql
- MySQL用source命令执行外部sql脚本文件时出现failed to open file的错误可能之一
- Scripts:找出磁盘读最多的SQL的脚本 perf_top_sql_by_disk_reads.sql
- Scripts:查询log file sync 等待的脚本lfsdiag.sql
- Scripts:报告物理数据库增长情况(注意脚本是看你数据库添加数据文件的时间哦)dba_db_growth.sql
- 每小时自动生成一个SQL Server Profiler文件(Auto Generate an Hourly SQL Server Profiler Trace File)
- Scripts:查出用户有未提交事务的脚本sess_uncommited_transactions.sql
- 通过后台文件(cs)向页面注册脚本