Home > Database > Mysql Tutorial > body text

Oracle 10 DBMS_MONITOR跟踪和分析其它session SQL

WBOY
Release: 2016-06-07 17:31:23
Original
1054 people have browsed it

Oracle 10 DBMS_MONITOR跟踪和分析其它session SQL

Oracle 10 DBMS_MONITOR跟踪和分析其它session SQL

1. session 信息

查看当前session信息语句

select sid, serial#, username, machine
from v$session
where type != 'BACKGROUND'
and username = 'SYS';

-- session 1 ----

session_id = 146
serial# = 18

-- session 2 --

session_id = 140
serial# = 31

2.执行过程

1)-- session 1 ----
-- start trace --
EXECUTE DBMS_MONITOR.SESSION_TRACE_ENABLE(session_id=>140, serial_num=>31, waits=>TRUE, binds=>TRUE);
#############################
2)-- session 2 --
执行SQL语句
###########################


3)-- session 1 ----

select sql_trace, sql_trace_waits, sql_trace_binds
from v$session
where sid = 140;

-- end trace --
EXECUTE DBMS_MONITOR.SESSION_TRACE_DISABLE(session_id=>140, serial_num=>31);

4)生成跟踪文件
跟踪结束自动生成session 2 SPID跟踪文件oradb1_ora_3732.trc

3.查看结果

1)查看session的SID、SERIAL#,process的PID、SPID

SQL> select s.sid, s.serial#, p.pid, p.spid
 2  from v$session s, v$process p
 3  where s.paddr = p.addr
 4  and s.username = 'SYS';

      SID    SERIAL#        PID SPID
---------- ---------- ---------- ------------
      140        31        16 3732
      146        18        17 4072

2)生成session 2 分析结果文件

tkprof C:\oracle\product\10.2.0\admin\oradb1\udump\oradb1_ora_3732.trc 3732.txt

推荐阅读:

[Oracle] dbms_metadata.get_ddl的用法总结 

使用DBMS_HPROF包收集PL/SQL性能信息

 [Oracle] 统计信息和dbms_stats包

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template