Problem solve Get help with specific problems with your technologies, process and projects.

Check the status of Oracle processes

This script correlates the operating system process with the Oracle process.

I generally run this script before shutting down the database to find out what the users are doing. It also gives the serial id -- the serial number neccessary to kill the session if needed. It correlates the operating system process with the Oracle process. You'll also be able to see the most current SQL run by that process. Therefore, if you find an OS process is consuming significant resources in a monitoring tool like top, you can run this SQL, correlate the OS process to the Oracle session identifier and see the most recent SQL executed. The script has been tested on 8.1.5.

SELECT pr.username "O/S Id",
       ss.username "Oracle User Id",
       ss.status "status",
       ss.sid "Session Id",
       ss.serial# "Serial No",
       lpad(pr.spid,7) "Process Id",
       substr(sqa.sql_text,1,540) "Sql Text"
  FROM v$process pr, v$session ss, v$sqlarea sqa
 WHERE pr.addr=ss.paddr
   AND ss.username is not null
   AND ss.sql_address=sqa.address(+)
   AND ss.sql_hash_value=sqa.hash_value(+)
ORDER BY 1,2,7

For More Information

  • Feedback: E-mail the editor with your thoughts about this tip.
  • More tips: Hundreds of free Oracle tips and scripts.
  • Tip contest: Have an Oracle tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize -- submit your tip today!
  • Ask the Experts: Our SQL, database design, Oracle, SQL Server, DB2, metadata, and data warehousing gurus are waiting to answer your toughest questions.
  • Forums: Ask your technical Oracle questions--or help out your peers by answering them--in our active forums.
  • Best Web Links: Oracle tips, tutorials, and scripts from around the Web.

This was last published in June 2003

Dig Deeper on Oracle database design and architecture

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchHRSoftware

Close