Querying SQL statements that Oracle is executing

Source: Internet
Author: User


--Query the SQL statement that Oracle is executing and the user who executes the statement

[SQL]View Plain copy
    1. select b.sid oracleid,   
    2.        b.username  Login Oracle user name,   
    3. Li class= "alt" >       B.SERIAL#,  
    4.         spid  operating system id,  
    5.         paddr,  
    6.        sql_text  executing sql,  
    7.        b.machine  computer name   
    8. FROM V$PROCESS A, V$SESSION B, V$SQLAREA C  
    9. where a.addr = b.paddr  
    10.    and b.sql_hash_value = c.hash_value  



--View the issuer's release procedure for executing SQL

[SQL]View Plain copy
  1. SELECT osuser Computer Login status,
  2. program that initiated the request,
  3. USERNAME user name of the login system,
  4. SCHEMANAME,
  5. B.cpu_time spends Cpu time,
  6. STATUS,
  7. SQL executed by B.sql_text
  8. From V$session A
  9. Left JOIN v$sql B on a.sql_address = b.address
  10. and A.sql_hash_value = B.hash_value
  11. ORDER by b.cpu_time DESC



--Identify Oracle's current locked object

[SQL]View Plain copy
  1. SELECT l.session_id SID,
  2. s.serial#,
  3. L.locked_mode lock mode,
  4. L.oracle_username logged in user,
  5. L.os_user_name Login Machine User name,
  6. S.machine machine Name,
  7. S.terminal End user Name,
  8. O.object_name is locked object name,
  9. S.logon_time Logon Database time
  10. From V$locked_object L, all_objects O, v$session s
  11. WHERE l.object_id = o.object_id
  12. and l.session_id = S.sid
  13. ORDER by Sid, S.serial#;


--kill drop the current lock object can be

Alter system kill session ' Sid, S.serial# ';

Querying SQL statements that Oracle is executing

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.