[20211019]V$DETACHED_SESSION檢視.txt
[20211019]V$DETACHED_SESSION檢視.txt
--//當不小心alter system kill session 'XXX,YYY'時,對應程式並沒有從OS清除。再使用原來的方法無法完全清除。
--//一般使用類似語句標識出來。
select spid, program from v$process
where program!= 'PSEUDO'
and addr not in (select paddr from v$session)
and addr not in (select paddr from v$bgprocess)
and addr not in (select paddr from v$shared_server);
--//注我的查詢這樣還是有問題,大家可以測試。
--//11g在v$session 增加了2個欄位CREATOR_ADDR,CREATOR_SERIAL#
CREATOR_ADDR - state object address of creating process
CREATOR_SERIAL# - serial number of creating process
--//執行如下:
SELECT spid, program
FROM v$process
WHERE addr in (SELECT creator_addr FROM v$session)
and addr not in (select paddr from v$session)
and addr not in (select paddr from v$bgprocess)
and addr not in (select paddr from v$shared_server);
--//實際上oracle還提供檢視V$DETACHED_SESSION,查詢它可能更快解決問題。透過例子說明:
1.環境:
SCOTT@book> @ ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
SCOTT@book> @ spid
SID SERIAL# PROCESS SERVER SPID PID P_SERIAL# C50
---------- ---------- ------------------------ --------- ------ ------- ---------- --------------------------------------------------
295 1359 36988 DEDICATED 36989 21 136 alter system kill session '295,1359' immediate;
2.測試:
SYS@book> alter system kill session '295,1359';
System altered.
select spid, program from v$process
where program!= 'PSEUDO'
and addr not in (select paddr from v$session)
and addr not in (select paddr from v$bgprocess)
and addr not in (select paddr from v$shared_server);
SPID PROGRAM
------ ------------------------------
36989 oracle@gxqyydg4 (TNS V1-V3)
57352 oracle@gxqyydg4 (D000)
--//可以發現多了一個D000程式不該殺。改寫如下:
SELECT spid, program
FROM v$process
WHERE addr in (SELECT creator_addr FROM v$session)
and addr not in (select paddr from v$session)
and addr not in (select paddr from v$bgprocess)
and addr not in (select paddr from v$shared_server);
SPID PROGRAM
------ ------------------------------
36989 oracle@gxqyydg4 (TNS V1-V3)
--//而查詢檢視V$DETACHED_SESSION也許更快。
SYS@book> select * from V$DETACHED_SESSION;
INDX PG_NAME SID SERIAL# PID
---------- ------------------------------ ---------- ---------- -------
0 DEFAULT 295 1359 21
--//根據sid,serial#輸出,直接執行:
alter system kill session '295,1359' immediate;
--//就可以kill對應程式。
--//也可以執行如下確定SPID程式號。
SELECT spid, program
FROM v$process
WHERE addr IN (SELECT creator_addr
FROM v$session
WHERE (sid, serial#) IN (SELECT sid, serial#
FROM V$DETACHED_SESSION));
SPID PROGRAM
------ ------------------------------
36989 oracle@gxqyydg4 (TNS V1-V3)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2838067/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20120307]檢視v$session檢視的定義.txtSession
- [20210528]V$INDEXED_FIXED_COLUMN檢視.txtIndex
- [20210418]查詢v$檢視問題.txt
- v$sql檢視和v$sqlarea檢視的構建SQL
- [20211214]檢視檢視V$ACTIVE_SESSION_HISTORY遇到奇怪問題.txtSession
- v$session 檢視Session
- 幾個檢視 v$mystat v$systata v$sessionSession
- 【會話】V$SESSION檢視會話Session
- oracle v$sysstat效能檢視Oracle
- Oracle常用的V$檢視Oracle
- Oracle 等待事件V$檢視Oracle事件
- v$resource_limit檢視MIT
- v檢視的授權
- v$sesstat,v$mystat,v$statname和v$sysstat檢視簡介
- 【Oracle九大效能檢視】之6.v$process檢視Oracle
- 使用V$SQL_PLAN檢視SQL
- V$SQLAREA 檢視TOP_SQLSQL
- Oracle中效能檢視V$SYSSTATOracle
- v$sql_plan 檢視解析SQL
- v$active_session_history檢視Session
- oracle V$PGASTAT檢視記錄OracleAST
- V$PGASTAT動態效能檢視AST
- 授權某使用者,檢視動態效能檢視的許可權(如v$latch,v$lock,v$sqlarea,v$sql,v$sysstat)SQL
- Oracle的V$檢視和DBA_檢視的參考提示Oracle
- v$sqlarea,v$sql,v$sqltext三個檢視的區別SQL
- [20200417]跟蹤特定sql語句以及v$open_cursor檢視.txtSQL
- v$active_session_history檢視[轉]Session
- Oracle的v$動態檢視 收藏Oracle
- V$ASM_DISK 檢視含義ASM
- V$session 檢視的小運用Session
- 自己總結的V$檢視(轉)
- 效能檢視 V$Session_LONGOPSSessionGo
- v$session_wait和v$session_event檢視SessionAI
- 【實驗】【檢視】使用v$bgprocess檢視獲得所有後臺程式資訊
- [20240911]檢視超長檢視的定義2.txt
- V$ACTIVE_SESSION_HISTORY檢視的使用Session
- 檢視hyper-v主機mac地址Mac
- V$SESSION_LONGOPS 檢視的用法SessionGo