主頁 > 知識庫 > oracle查詢鎖表與解鎖情況提供解決方案

oracle查詢鎖表與解鎖情況提供解決方案

熱門標簽:地圖標注付款了怎么找不到了 北京外呼系統(tǒng)公司排名 沈陽400電話是如何辦理 北京營銷外呼系統(tǒng)廠家 百度地圖標注員是干什么 溫州人工外呼系統(tǒng) 貴陽智能電銷機器人官網(wǎng) 外呼系統(tǒng)鄭州 外呼系統(tǒng)口號

如果發(fā)生了鎖等待,我們可能更想知道是誰鎖了表而引起誰的等待
以下的語句可以查詢到誰鎖了表:

復(fù)制代碼 代碼如下:

SELECT /*+ rule */ s.username,
decode(l.type,'TM','TABLE LOCK',
'TX','ROW LOCK',
NULL) LOCK_LEVEL,
o.owner,o.object_name,o.object_type,
s.sid,s.serial#,s.terminal,s.machine,s.program,s.osuser
FROM v$session s,v$lock l,dba_objects o
WHERE l.sid = s.sid
AND l.id1 = o.object_id(+)
AND s.username is NOT NULL

以下的語句可以查詢到誰在等待:
復(fù)制代碼 代碼如下:

SELECT /*+ rule */ lpad(' ',decode(l.xidusn ,0,3,0))||l.oracle_username User_name, o.owner,o.object_name,o.object_type,s.sid,s.serial#
FROM v$locked_object l,dba_objects o,v$session s
WHERE l.object_id=o.object_id
AND l.session_id=s.sid
ORDER BY o.object_id,xidusn DESC

解鎖命令:
復(fù)制代碼 代碼如下:

alter system kill session 'sid,serial#'

1).
復(fù)制代碼 代碼如下:

select LOCK_INFO.OWNER || '.' || LOCK_INFO.OBJ_NAME as "已鎖物件名稱", --物件名稱(已經(jīng)被鎖住)
LOCK_INFO.SUBOBJ_NAME as "已鎖子物件名稱", -- 子物件名稱(已經(jīng)被鎖住)
SESS_INFO.MACHINE as "機器名稱", -- 機器名稱
LOCK_INFO.SESSION_ID as "會話ID", -- 會話SESSION_ID
SESS_INFO.SERIAL# as "會話SERIAL#", -- 會話SERIAL#
SESS_INFO.SPID as "OS系統(tǒng)的SPID", -- OS系統(tǒng)的SPID
(SELECT INSTANCE_NAME FROM V$INSTANCE) "實例名SID", --實例名SID
LOCK_INFO.ORA_USERNAME as "ORACLE用戶", -- ORACLE系統(tǒng)用戶名稱
LOCK_INFO.OS_USERNAME as "OS用戶", -- 作業(yè)系統(tǒng)用戶名稱
LOCK_INFO.PROCESS as "進程編號", -- 進程編號
LOCK_INFO.OBJ_ID as "對象ID", -- 對象ID
LOCK_INFO.OBJ_TYPE as "對象類型", -- 對象類型
SESS_INFO.LOGON_TIME as "登錄時間", -- 登錄時間
SESS_INFO.PROGRAM as "程式名稱", -- 程式名稱
SESS_INFO.STATUS as "會話狀態(tài)", -- 會話狀態(tài)
SESS_INFO.LOCKWAIT as "等待鎖", -- 等待鎖
SESS_INFO.ACTION as "動作", -- 動作
SESS_INFO.CLIENT_INFO as "客戶資訊" -- 客戶資訊
from (select obj.OWNER as OWNER,
obj.OBJECT_NAME as OBJ_NAME,
obj.SUBOBJECT_NAME as SUBOBJ_NAME,
obj.OBJECT_ID as OBJ_ID,
obj.OBJECT_TYPE as OBJ_TYPE,
lock_obj.SESSION_ID as SESSION_ID,
lock_obj.ORACLE_USERNAME as ORA_USERNAME,
lock_obj.OS_USER_NAME as OS_USERNAME,
lock_obj.PROCESS as PROCESS
from (select *
from all_objects
where object_id in (select object_id from v$locked_object)) obj,
v$locked_object lock_obj
where obj.object_id = lock_obj.object_id) LOCK_INFO,
(select SID,
SERIAL#,
LOCKWAIT,
STATUS,
(select spid from v$process where addr = a.paddr) spid,
PROGRAM,
ACTION,
CLIENT_INFO,
LOGON_TIME,
MACHINE
from v$session a) SESS_INFO
where LOCK_INFO.SESSION_ID = SESS_INFO.SID
order by LOCK_INFO.SESSION_ID;

2).
復(fù)制代碼 代碼如下:

select sql_text
from v$sqltext
where address in (select sql_address from v$session where sid = sid)
order by piece;

3).
復(fù)制代碼 代碼如下:

ALTER SYSTEM KILL SESSION '會話ID,會話SERIAL#';

4).
kill -9 OS系統(tǒng)的SPID

您可能感興趣的文章:
  • 查看Oracle中是否有鎖表的sql
  • 深入探討:Oracle中如何查詢正鎖表的用戶以及釋放被鎖的表的方法
  • oracle查詢鎖表及解鎖,修改表字段名與復(fù)制表結(jié)構(gòu)和數(shù)據(jù)的方法
  • oracle處理鎖表基本操作
  • oracle鎖表該如何解決

標簽:淮北 定西 衡水 通遼 衢州 潮州 溫州 包頭

巨人網(wǎng)絡(luò)通訊聲明:本文標題《oracle查詢鎖表與解鎖情況提供解決方案》,本文關(guān)鍵詞  oracle,查詢,鎖表,與,解鎖,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《oracle查詢鎖表與解鎖情況提供解決方案》相關(guān)的同類信息!
  • 本頁收集關(guān)于oracle查詢鎖表與解鎖情況提供解決方案的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章