Oracle – Sessions Logged In

Often it is nice to see who is logged in to a database.  This is a simple script I use.
This script is called sid.sql

set linesize 132
set pagesize 100

ttitle on
ttitle center '*****  Connected Users  *****' skip 2

clear breaks

column sid                format 9999         heading 'SID'
column serial#            format 99999        heading 'Ser#'
column username           format a18          heading 'User'
column osuser             format a15          heading 'OS User'
column status             format a8           heading 'Status'
column program            format a40          heading 'Program'
column machine            format a25          heading 'Machine'
column last_call_et       format 999999       heading 'Last'

SELECT s.sid, s.serial#, s.username, s.osuser, s.status,
       SUBSTR( NVL( s.module, s.program ), 1, 40 ) program,
       s.machine, s.last_call_et
FROM   v$session s
WHERE  s.username IS NOT NULL
AND    s.type <> 'BACKGROUND';

ttitle off
clear breaks

These scripts are designed to run on a window that is at least 132 characters wide.

Just a note, I am on a Windows machine and my databases are on Linux, so I use an X-Term window software named X-Win32.  In case you are looking for an X-Term software for windows I like this one and it doesn’t cost much.

Post a Comment