Check session id and serial# for session connected in Oracle

Check session id and serial# for session connected in Oracle

Get the SID of current session

--Get the SID of current session
SELECT SYS_CONTEXT ('USERENV', 'SID') FROM DUAL;

SYS_CONTEXT('USERENV','SID')
-----------------------------
11

--You can get from mystat view also
select sid from v$mystat where rownum <=1;

SID
----------
11

Get Serial# of current session

select 'SID = '||sid||' Serial# = '||serial# SID_SR_TXT from v$session
where sid in (select sid from v$mystat where rownum <=1);

SID_SR_TXT
---------------------------
SID = 11 Serial# = 39815