檢視引起阻塞的Session
使用者A執行刪除,但是沒有提交。
SQL> delete from test where object_id<10;
已刪除8行。
使用者B執行刪除或者更新id<10的記錄,則被阻塞。
SQL> update test set flag='N' where object_id<10;
遇到這種阻塞,首先需要確定問題。可以使用以下指令碼。
結果如下:
USERNAME SID SERIAL# LOGON_TIME
------------------------------ ---------- ---------- --------------
LIHUILIN 14 87 09-11月-13
LIHUILIN 139 655 09-11月-13
或者使用
結果如下:
BLOCKER SID 'ISBLOCKING' BLOCKEE SID
------------------------------ ---------- ------------- ------------------------------ ----------
LIHUILIN 14 is blocking LIHUILIN 139
Kill引起阻塞的Session
結果如下:
CMD
-----------------------------------------
alter system kill session '14,87';
最後執行alter system命令,阻塞解除。
SQL> delete from test where object_id<10;
已刪除8行。
使用者B執行刪除或者更新id<10的記錄,則被阻塞。
SQL> update test set flag='N' where object_id<10;
遇到這種阻塞,首先需要確定問題。可以使用以下指令碼。
-
select t2.username,t2.sid,t2.serial#,t2.logon_time
-
from v$locked_object t1,v$session t2
- where t1.session_id=t2.sid order by t2.logon_time;
USERNAME SID SERIAL# LOGON_TIME
------------------------------ ---------- ---------- --------------
LIHUILIN 14 87 09-11月-13
LIHUILIN 139 655 09-11月-13
或者使用
-
select
-
(select username from v$session where sid=a.sid) blocker,
-
a.sid,' is blocking ',
-
(select username from v$session where sid=b.sid) blockee,
-
b.sid
-
from v$lock a,v$lock b
- where a.block=1 and b.request>0 and a.id1=b.id1 and a.id2=b.id2;
BLOCKER SID 'ISBLOCKING' BLOCKEE SID
------------------------------ ---------- ------------- ------------------------------ ----------
LIHUILIN 14 is blocking LIHUILIN 139
Kill引起阻塞的Session
- select 'alter system kill session '''||sid||','||serial#||''';' cmd from v$session where username='LIHUILIN' and sid=14;
CMD
-----------------------------------------
alter system kill session '14,87';
最後執行alter system命令,阻塞解除。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29254281/viewspace-776209/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- v$session 檢視Session
- update引起資料庫阻塞資料庫
- 【轉】檢視Oracle資料庫阻塞Oracle資料庫
- V$session 檢視的小運用Session
- 瀏覽器檢視Session瀏覽器Session
- 【會話】V$SESSION檢視會話Session
- 檢視oracle當前sessionOracleSession
- Oracle中診斷阻塞的sessionOracleSession
- oracle session阻塞查詢OracleSession
- blocking_session阻塞BloCSession
- V$ACTIVE_SESSION_HISTORY檢視的使用Session
- 檢視鎖定的session資訊指令碼Session指令碼
- V$SESSION_LONGOPS 檢視的用法SessionGo
- v$active_session_history檢視Session
- V$session 及該檢視的小運用Session
- v$session_wait和v$session_event檢視SessionAI
- SESSION_PRIVS和SESSION_ROLES動態檢視Session
- session檢視中wait_timeSessionAI
- v$active_session_history檢視[轉]Session
- 效能檢視 V$Session_LONGOPSSessionGo
- [20120307]檢視v$session檢視的定義.txtSession
- open session in view引起的事務問題SessionView
- 轉載--V$ACTIVE_SESSION_HISTORY檢視的使用Session
- V$ACTIVE_SESSION_HISTORY 檢視中包含的資訊Session
- 檢視ASP Session 變數的小工具 (轉)Session變數
- 檢視過去的session鎖情況指令碼Session指令碼
- Oracle等待檢視v$session_waitOracleSessionAI
- 檢視當前會話session id方法:會話Session
- 【Oracle】gv$px_session 檢視介紹OracleSession
- windows下檢視oracle 執行緒 (session)WindowsOracle執行緒Session
- 查詢引起Oracle阻塞事件的源頭語句的方法Oracle事件
- Oracle檢視已被使用的open_cursors&session_cached_cursorsOracleSession
- 使用DBMS_UTILITY.get_parameter_value檢視session的parameterSession
- v$session檢視中的sid和serial#研究Session
- adop -status 檢視pending ADOP sessionSession
- 幾個檢視 v$mystat v$systata v$sessionSession
- Oracle中診斷阻塞session的方法 blocking errorOracleSessionBloCError
- 檢視歷史會話等待事件對應的session資訊會話事件Session