Pid,sid search each other, query sql according to PID
There are three ways to view the session ID of the current session:
1. V$mystat view
SQL > select sid from v$mystat where rownum=1
SID
-
1152
two。 Get it directly using userenv ('sid')
This method can only be used after oracle 10g.
SQL > select userenv ('sid') from dual
Pid,sid looks for each other:
V$session_wait
V$session
V$sqltext
V$process
/ pid finds sid/ (if the process cannot find it, it is not an oracle process) /
/ sid found pid/ (possibly caused by something else)
Supplement 1:
Find the sql statement according to pid
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
Supplement 2:
According to pid, find the sid,serial#, and delete it.
Select sid,serial# FROM v$session b
WHERE b.paddr = (SELECT addr
FROM v$process c
WHERE c.spid ='& pid')
ORDER BY piece ASC
Description: the spid- of v$process here is the pid of top.
Supplement 3:
Find PID= according to sid,serial#,.
Select c.spid from v$process c where c.addr = (select b.paddr from v$session b where b.sid=''and b.serialkeeper ='')