oracle查询锁表与解锁
------ 查询被锁的会话、表、主机等
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;
--查看数据库引起锁表的SQL语句
SELECT A.USERNAME, A.MACHINE, A.PROGRAM, A.SID, A.SERIAL#, A.STATUS, C.PIECE, C.SQL_TEXT
FROM V$SESSION A, V$SQLTEXT C
WHERE A.SID IN (SELECT DISTINCT T2.SID
FROM V$LOCKED_OBJECT T1, V$SESSION T2
WHERE T1.SESSION_ID = T2.SID)
AND A.SQL_ADDRESS = C.ADDRESS(+)
ORDER BY C.PIECE;
Linux数据库服务器下用sqlplus登陆
第一步: 切换到oracle的用户
$: su -oracle
第二步,连接数据库,用dba身份启动
$: sqlplus / as sysdba
第三步:
--- 删除session , 'sid, SERIAL'
ALTER SYSTEM KILL SESSION '3522,49241';