锁表查看与解除 --查看锁表情况 select object_name,machine,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;
在Oracle中查询锁表及解锁:
锁表查询的代码有以下的形式:
select count(*) from v$locked_object;
select * from v$locked_object;
查看哪个表被锁:
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
1、查询进程
show processlist
2、 查询到相对应的进程,然后 kill id
验证(kill后再看是否还有锁)
2、查询是否锁表
show OPEN TABLES where In_use > 0;
示例:
新建一个会话执行如下的显示锁示例
LOCK TABLES account_data.account READ;
SELECT SLEEP(160);
UNLOCK TABLES account_data.account;
另开启一个会话检查锁表情况:
my