The New Home of Oracle-wiki.net
All things oracle...
A website for IT Professionals involved with Oracle database.
List Session ID for a Given OS Process ID
--
-- List Session ID for a Given OS Process ID.
--
SET PAUSE ON
SET PAUSE 'Press Return to Continue'
SET PAGESIZE 60
SET LINESIZE 300
SELECT
CHR(10)||
'Check for SESSION ID ----> '||LPAD( s.sid, 4 )||CHR(10)||CHR(10) as "Session ID"
FROM
v$session s, v$process p
WHERE
p.addr = s.paddr AND
p.spid = &Enter_OSPid
/
Looks up the Oracle session ID (SID) that corresponds to a given operating system process ID. It allows you input the OS level process ID, one identified through ps, top, or an OS alert, and map it to an Oracle session connected to that OS PID.
Use this when you have identified a problem process at the OS level, for example a process consuming high CPU or memory, and need to trace it back to the Oracle session and, from there, the SQL or user responsible.
Running the script will prompt for:
Enter the OSPid - the OS process ID (SPID) to look up
Published on
Published 25th September 2026