Get the App
SLTechnology News&Howtos  ›  Database  › 

Pid,sid search each other, query sql according to PID

Shulou Source: shulou.com Published: 2022-06-01 05:53:07 10月30日 Update

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 ='')

Tags: Methods processes that is views statements queries Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker MySQL Shulou Information OPPO Reno vpn