今天执行UPDATE语句的时候等了一分多钟发现sql语句还没有执行结束, 上网搜索了一边才知道原来是线程锁住了, 下次在遇到这种问题直接按照步骤执行下面的sql语句就可以了很简单
1.执行sql语句, 查看被锁住的线程
SELECT SESS.SID,
SESS.SERIAL#,
LO.ORACLE_USERNAME,
LO.OS_USER_NAME,
AO.OBJECT_NAME,
LO.LOCKED_MODE
FROM V$LOCKED_OBJECT LO, DBA_OBJECTS AO, V$SESSION SESS
WHERE AO.OBJECT_ID = LO.OBJECT_ID
AND LO.SESSION_ID = SESS.SID;
2.执行下面sql语句将卡死的线程杀死, sql里面的字符串值是上面查询出被锁的线程id 'SID,SERIAL#' 两个id中间用逗号隔开
ALTER SYSTEM KILL SESSION 'SID,SERIAL#';
3.完整的sql语句
SELECT SESS.SID,
SESS.SERIAL#,
LO.ORACLE_USERNAME,
LO.OS_USER_NAME,
AO.OBJECT_NAME,
LO.LOCKED_MODE,
'ALTER SYSTEM KILL SESSION ''' || SESS.SID || ',' || SESS.SERIAL# ||
''';'
FROM V$LOCKED_OBJECT LO, DBA_OBJECTS AO, V$SESSION SESS
WHERE AO.OBJECT_ID = LO.OBJECT_ID
AND LO.SESSION_ID = SESS.SID;