查看當前會話的session ID 有如下三種方法:
1. v$mystat視圖
SQL> select sid from v$mystat where rownum=1;
SID
----------
1152
2. 使用userenv(‘sid’) 直接獲取
這種方法只能在oracle 10g以后可以使用。
SQL> select userenv('sid') from dual;
pid,sid相互查找:
v$session_wait
v$session
v$sqltext
v$process
///////pid找到sid///////// (假如進程找不到,那就不是oracle的進程)////
/////sid找到pid///////////(可能其他導致的)
補充1:
根據(jù)pid找到sql語句
SELECT
sql_text,hash_value
FROM v$sqltext a
WHERE (a.hash_value, a.address) IN (
SELECT DECODE (sql_hash_value,
0, prev_hash_value,
sql_hash_value
),
DECODE (sql_hash_value, 0, prev_sql_addr, sql_address)
FROM v$session b
WHERE b.paddr = (SELECT addr
FROM v$process c
WHERE c.spid = '&pid'))
ORDER BY piece ASC
補充2:
根據(jù)pid,找到sid,serial#,再刪除
select sid,serial# FROM v$session b
WHERE b.paddr = (SELECT addr
FROM v$process c
WHERE c.spid = '&pid')
ORDER BY piece ASC
說明: 這里的v$process的spid-就是top中的pid
補充3:
根據(jù)sid,serial#,找到PID=
Select c.spid from v$process c where c.addr=(select b.paddr from v$session b where b.sid= ' ' and b.serial#= ' ')
當前名稱:pid,sid相互查找,根據(jù)PID查詢sql
URL分享:
http://weahome.cn/article/ghpicg.html