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

來源:互聯網
上載者:User

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包

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.