Oacle 조회 잠 금 표 와 잠 금 해제 상황 해결 방안 제공

만약 에 자물쇠 대기 가 발생 하면 우 리 는 누가 시 계 를 잠 갔 는 지 알 고 싶 어서 누구의 기다 림 을 일 으 켰 는 지 다음 과 같은 문 구 를 통 해 누가 시 계 를 잠 갔 는 지 알 수 있 습 니 다.
 
  
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

다음 문 구 는 누가 기다 리 고 있 는 지 알 수 있 습 니 다.
 
  
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

잠 금 해제 명령:
 
  
alter system kill session 'sid,serial#'

1).
 
  
select LOCK_INFO.OWNER || '.' || LOCK_INFO.OBJ_NAME as " �i �Q", -- �Q( � �i )
LOCK_INFO.SUBOBJ_NAME as " �i �Q", -- �Q( � �i )
SESS_INFO.MACHINE as "�C �Q", -- �C �Q
LOCK_INFO.SESSION_ID as "���ID", -- ���SESSION_ID
SESS_INFO.SERIAL# as "���SERIAL#", -- ���SERIAL#
SESS_INFO.SPID as "OS �y SPID", -- OS �y SPID
(SELECT INSTANCE_NAME FROM V$INSTANCE) "�� SID", --�� SID
LOCK_INFO.ORA_USERNAME as "ORACLE ��", -- ORACLE �y � ��Q
LOCK_INFO.OS_USERNAME as "OS ��", -- �I �y � ��Q
LOCK_INFO.PROCESS as "�M ��", -- �M ��
LOCK_INFO.OBJ_ID as "�ο�ID", -- �ο�ID
LOCK_INFO.OBJ_TYPE as "�ο � ", -- �ο �
SESS_INFO.LOGON_TIME as " ��r�g", -- ��r�g
SESS_INFO.PROGRAM as " �Q", -- �Q
SESS_INFO.STATUS as "�����B", -- �����B
SESS_INFO.LOCKWAIT as " �i", -- �i
SESS_INFO.ACTION as "� �", -- � �
SESS_INFO.CLIENT_INFO as " � Y�" -- � Y�
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).
 
  
select sql_text
from v$sqltext
where address in (select sql_address from v$session where sid = &sid)
order by piece;

3).
 
  
ALTER SYSTEM KILL SESSION '���ID,���SERIAL#';

4).
kill - 9 OS 계열 엔 이의 SPID

좋은 웹페이지 즐겨찾기