-- 특정 테이블에 LOCK 확인
SELECT A.SID, A.SERIAL#, B.TYPE, C.OBJECT_NAME
FROM V$SESSION A, V$LOCK B, DBA_OBJECTS C
WHERE A.SID = B.SID
AND B.ID1 = C.OBJECT_ID
AND B.TYPE='TM'
AND C.OBJECT_NAME IN ('TB_CO_GENO');
-- LOCK 테이블 확인
SELECT DO.OBJECT_NAME, DO.OWNER, DO.OBJECT_TYPE, DO.OWNER,
VO.XIDUSN, VO.SESSION_ID, VO.LOCKED_MODE
FROM V$LOCKED_OBJECT VO, DBA_OBJECTS DO
WHERE VO.OBJECT_ID = DO.OBJECT_ID;
-- 락발생 사용자와 SQL, OBJECT 조회
SELECT DISTINCT X.SESSION_ID, A.SERIAL#, D.OBJECT_NAME, A.MACHINE, A.TERMINAL,
A.PROGRAM, B.ADDRESS, B.PIECE, B.SQL_TEXT
FROM V$LOCKED_OBJECT X, V$SESSION A, V$SQLTEXT B, DBA_OBJECTS D
WHERE X.SESSION_ID = A.SID
AND X.OBJECT_ID = D.OBJECT_ID
AND A.SQL_ADDRESS = B.ADDRESS
ORDER BY B.ADDRESS, B.PIECE;
-- 현재 접속자의 SQL 분석
SELECT DISTINCT A.SID, A.SERIAL#,
A.MACHINE, A.TERMINAL, A.PROGRAM,
B.ADDRESS, B.PIECE, B.SQL_TEXT
FROM V$SESSION A, V$SQLTEXT B
WHERE A.SQL_ADDRESS = B.ADDRESS
ORDER BY A.SID, A.SERIAL#, B.ADDRESS, B.PIECE
-- 락 세션 죽이기
SELECT A.SID, A.SERIAL#
FROM V$SESSION A, V$LOCK B, DBA_OBJECTS C
WHERE A.SID = B.SID
AND B.ID1 = C.OBJECT_ID
AND B.TYPE = 'TM'
AND C.OBJECT_NAME = 'TB_CO_GENO'
SID SERIAL#
--- -------
5 1
6 1
2. 다음 명령으로 SESSION들을 KILL한다. ALTER SYSTEM KILL SESSION 'SESSION_ID, SERIAL#';
SQL> alter system kill session '5, 1';
SQL> alter system kill session '6, 1';
-- 락 세션 죽이는 sql 문
SELECT DISTINCT
X.SESSION_ID,
A.SERIAL#,
D.OBJECT_NAME,
A.MACHINE,
A.TERMINAL,
A.PROGRAM,
A.LOGON_TIME,
'ALTER SYSTEM KILL SESSION'''||A.SID||', '||A.SERIAL#||''';'
FROM GV$LOCKED_OBJECT X, GV$SESSION A, DBA_OBJECTS D
WHERE X.SESSION_ID = A.SID
AND X.OBJECT_ID = D.OBJECT_ID
ORDER BY LOGON_TIME;
'IT > Oracle' 카테고리의 다른 글
오라클 페이징 쿼리. (0) | 2022.02.18 |
---|---|
엑셀 import Valid 체크 및 MyBatis 다중 루프 시 변수 처리 (0) | 2021.02.04 |
오라클 CONNECT BY - 재귀호출 / 계층형 쿼리 (0) | 2021.02.03 |
오라클 조건문에 특수문자 & or % or ? 문자로 인식시키기 (0) | 2021.02.03 |
오라클 문자에 특정문자가 몇개나 있는지 검색하는 법 (0) | 2021.02.03 |
댓글