denrepo

OracleSessions

Find the session behind an OS process ID

When top or ps shows an Oracle process burning CPU, enter its PID to see which session and SQL it belongs to.

Prompts for input

Not yet verified. How scripts are tested

ora-spid.sql
1CLEAR COLUMNS2SET LINESIZE 180 PAGESIZE 100 TRIMOUT ON TAB OFF VERIFY OFF3COLUMN sid_serial HEADING "SID,SERIAL#" FORMAT A144COLUMN username   FORMAT A155COLUMN program    FORMAT A30 TRUNCATE6COLUMN status     FORMAT A87COLUMN sql_id     FORMAT A138COLUMN event      FORMAT A35 TRUNCATE9 10SELECT s.sid || ',' || s.serial# AS sid_serial,11       s.username, s.program, s.status, s.sql_id, s.event12FROM v$process p13JOIN v$session s ON s.paddr = p.addr14WHERE p.spid = '&os_pid';

Save it as ora-spid.sql and run it with SQL> @ora-spid.

Open in denrepo

More Oracle scripts: Sessions