SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is enabled
SQL> create role plustrace;
Role created.
SQL> grant select on v_$sesstat to plustrace;
Grant succeeded.
SQL> grant select on v_$statname to plustrace;
Grant succeeded.
SQL> grant select on v_$mystat to plustrace;
Grant succeeded.
SQL> grant plustrace to dba with admin option;
Grant succeeded.
SQL> grant plustrace to STORM;
Grant succeeded.
重新登录storm
SQL> set autotrace on statistics
USERNAME SID SERIAL# SERVER PADDR STATUS
------------------------------ ---------- ---------- --------- -------- --------
STORM 141 180 DEDICATED 30A1BDCC INACTIVE
STORM 148 62 DEDICATED 30A1BDCC INACTIVE
SQL> disconnect
从技术上讲,这个命令应该叫DESTROY_ALL_SESSIONS更合适,而不是DISCONNECT,因为我们并没有真正物理地断开连接。
在SQL*Plus中要真正地断开连接,应该执行“exit”命令,因为你必须退出才能完全撤销连接。
SQL> select username, sid, serial#, server, paddr, status from v$session where username = 'STORM';
no rows selected
可以看到,这个账户名下没有会话,但是仍有一个进程,相应地有一条物理连接(使用前面的ADDR值)
SQL> select username, program from v$process where addr = hextoraw('30A1BDCC');
USERNAME PROGRAM
--------------- ------------------------------------------------
oracle oracle@hb (TNS V1-V3)
SQL>
所以,这就有了一条没有相关会话的“连接”。可以使用SQL*Plus的CONNECT命令(这个命令的名字也起得不恰当),在这个现有的进程中创建一个新会话(CONNECT命令叫CREATE_SESSION更合适):可以看到,这个账户名下没有会话,但是仍有一个进程,相应地有一条物理连接(使用前面的ADDR值)
SQL> select username, sid, serial#, server, paddr, status from v$session where username = 'STORM';
USERNAME SID SERIAL# SERVER PADDR STATUS
------------------------------ ---------- ---------- --------- -------- --------
STORM 153 58 DEDICATED 30A1BDCC INACTIVE
可以注意到,PADDR还是一样的,所以我们还是在使用同一条物理连接,但是(可能)有一个不同的SID。我说“可能有”,是因为也许还会分配同样的SID,这取决于在我们注销时是否有别人登录,以及我们原来的SID是否可用。
另外:
Serial# is in v$session. It is an Oracle generated value used in
combination with the SID to create a unique session identifier.
SID和SERIAL合起来能作为一个session的唯一标识。