[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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20211019]ffmpeg為視訊新增字幕.txt
- [20210528]V$INDEXED_FIXED_COLUMN檢視.txtIndex
- [20210418]查詢v$檢視問題.txt
- [20211214]檢視檢視V$ACTIVE_SESSION_HISTORY遇到奇怪問題.txtSession
- [20181103]12c檢視V$EVENT_NAME.txt
- [20201207]12c v$open_cursor檢視.txt
- [20190312]檢視v$datafile欄位OFFLINE_CHANGE#, ONLINE_CHANGE#.txt
- [20180907]訪問v$檢視與一致性讀取.txt
- [20200211]檢視v$db_object_cache的CHILD_LATCH欄位.txtObject
- [20200212]使用DBMS_SHARED_POOL.MARKHOT與檢視v$open_cursor.txt
- [20200417]跟蹤特定sql語句以及v$open_cursor檢視.txtSQL
- [20180503]檢視提示使用索引.txt索引
- [20240911]檢視超長檢視的定義2.txt
- [20200422]跟蹤特定sql語句以及v$open_cursor檢視(補充).txtSQL
- [20200417]跟蹤特定sql語句以及v$open_cursor檢視2.txtSQL
- 檢視V$DATAGUARD_STATS
- [20230323]ps命令檢視thread.txtthread
- [20200424]跟蹤特定sql語句以及v$open_cursor檢視(再補充).txtSQL
- [20221130]測試訪問檢視v$session幾種情況的效能差異.txtSession
- [20190416]檢視shared latch gets的變化.txt
- [20231012]如何檢視unicode編碼內容.txtUnicode
- [20190324]奇怪的GV$FILESPACE_USAGE檢視.txt
- [20190104]ipcs檢視共享記憶體段.txt記憶體
- [20211206]toad下job建立檢視問題.txt
- [20210422]如何檢視字元的ascii編碼.txt字元ASCII
- [20210423]建立檢視以及欄位長度.txt
- [20180814]慎用檢視錶壓縮率指令碼.txt指令碼
- [20190506]檢視巢狀與繫結變數.txt巢狀變數
- [20210207]使用gdb檢視等待事件11g.txt事件
- [20210208][20200426]檢視shared latch gets的變化.txt
- V$ACTIVE_SESSION_HISTORY檢視的使用Session
- [20181004]12c dba_source檢視定義.txt
- 讓你在macOS上快速檢視txt文字檔案Mac
- [20180322]檢視統計資訊的儲存歷史.txt
- [20221128]再談防水牆(檢視訪問效能問題).txt
- [20210114]toad檢視真實執行計劃問題.txt
- ORACLE 閃回檢視v$flashback_database_log/statOracleDatabase
- [20190125]簡單快速檢視那些sql語句正在執行.txtSQL