--oracle 锁 (查询/解锁语句)
-- 查看哪个表被锁
select b.owner,b.object_name,a.session_id,a.locked_mode
from v$locked_object a,dba_objects b
where b.object_id = a.object_id
--查看是哪个session引起的
select b.username,b.sid,b.serial#,logon_time
from v$locked_object a,v$session b
where a.session_id = b.sid order by b.logon_time
通过 select * from table where id=16701 for update 锁住一张表
--通过以下语句可查询出被锁住的对象
SELECT OBJECT_ID,
SESSION_ID,
SERIAL#,
ORACLE_USERNAME,
OS_USER_NAME,
S.PROCESS
FROM V$LOCKED_OBJECT A, V$SESSION S
WHERE A.SESSION_ID = S.SID
--通过下列语句进行解锁
alter system kill session 'sid,serial#';
-- 查看哪个表被锁
select b.owner,b.object_name,a.session_id,a.locked_mode
from v$locked_object a,dba_objects b
where b.object_id = a.object_id
--查看是哪个session引起的
select b.username,b.sid,b.serial#,logon_time
from v$locked_object a,v$session b
where a.session_id = b.sid order by b.logon_time
通过 select * from table where id=16701 for update 锁住一张表
--通过以下语句可查询出被锁住的对象
SELECT OBJECT_ID,
SESSION_ID,
SERIAL#,
ORACLE_USERNAME,
OS_USER_NAME,
S.PROCESS
FROM V$LOCKED_OBJECT A, V$SESSION S
WHERE A.SESSION_ID = S.SID
--通过下列语句进行解锁
alter system kill session 'sid,serial#';