The following example demonstrates three ways to display current session sid of the user - SCOTT :

conn / as sysdba
accept pwd hide
create user scott identified by &pwd;

grant connect to scott;
grant select on v_$mystat to scott;

conn scott/&pwd
SQL> sho user
USER is "SCOTT"

-- Method 1
col sid format 9999999999
SQL> select sid from v$mystat where rownum = 1;
       SID
----------
       589

-- Method 2
col sid format a10
SQL> select sys_context('USERENV','SID') as sid from dual;

SID
----------
589

-- Method 3
col sid format 9999999999
SQL> select to_number(substr(dbms_session.unique_session_id,1,4),'XXXX') as sid from dual;

       SID
----------
       589

[Reference]
http://www.dba-oracle.com/t_how_to_display_session_id_sid.htm


 

arrow
arrow
    全站熱搜

    DanBrother 發表在 痞客邦 留言(0) 人氣()