Oracle10DBMS_MONITOR tracks and analyzes other sessionSQL statements

Source: Internet
Author: User
Oracle10DBMS_MONITOR tracks and analyzes other sessionSQL statements

Oracle 10 DBMS_MONITOR tracks and analyzes other session SQL statements

Oracle 10 DBMS_MONITOR tracks and analyzes other session SQL statements

1. session information

View the current session information statement

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. Execution Process

1) -- session 1 ----
-- Start trace --
EXECUTE DBMS_MONITOR.SESSION_TRACE_ENABLE (session_id => 140, serial_num => 31, waits => TRUE, binds => TRUE );
#############################
2) -- session 2 --
Execute SQL statements
###########################


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 = & gt; 140, serial_num = & gt; 31 );

4) generate a trail File
Automatically generate session 2 SPID tracking file oradb1_ora_3732.trc after tracking ends

3. view results

1) View session SID, SERIAL #, process PID, and 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) generate session 2 analysis result File

Tkprof C: \ oracle \ product \ 10.2.0 \ admin \ oradb1 \ udump \ oradbw.ora_3732.trc 3732.txt

Recommended reading:

[Oracle] dbms_metadata.get_ddl usage Summary

Use the DBMS_HPROF package to collect PL/SQL Performance Information

[Oracle] statistics and dbms_stats packages

,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.