MsSqlserver 查看锁表与解锁

查看被锁表:

select   request_session_id   spid,OBJECT_NAME(resource_associated_entity_id) tableName
from   sys.dm_tran_locks where resource_type=‘OBJECT‘

spid   锁表进程
tableName   被锁表名

解锁:

declare @spid  int
Set @spid  = 57 --锁表进程
declare @sql varchar(1000)
set @sql=‘kill ‘+cast(@spid  as varchar)
exec(@sql)
 
时间: 2024-10-24 21:00:07

MsSqlserver 查看锁表与解锁的相关文章

pl/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 ② 解锁语句 alter system kil

Oracle查看锁表和解锁

--注意权限问题 1.查看是否有被锁的表: 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 2.查看是哪个进程锁的 select b.username,b.sid,b.serial#,logon_time from v$locked_object a,v$session b where a.ses

Oracle查看锁表与解锁方法

--查看 select a.object_name,b.session_id,c.serial#,c.program,c.username,c.command,c.machine,c.lockwait from all_objects a,v$locked_object b,v$session c where a.object_id=b.object_id and c.sid=b.session_id; --解锁 alter system kill session'session_id,seri

sqlserver锁表、解锁、查看锁表

? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 面演示一个实例,它使用sys.dm_tran_locks动态视图监视数据库中锁的活动. 打开一个查询窗口,执行如下语句: USE AdventureWorks BEGIN TRAN SELECT ProductID, ModifiedDate FROM Production.ProductDocument WITH (TABLOCKX) 打开另一个查询窗口

Oracle锁表、解锁

我遇到的情况: 当使用select语句查询表时,后面跟着for update , select * from table for update 当修改表中数据,但是没有commit就关掉PL/SQL,下次再打开执行上面sql语句,就会卡死,不能再for update 一.锁表 查看锁表进程SQL语句: select * from v$session t1, v$locked_object t2 where t1.sid = t2.SESSION_ID; 如果有记录,可查到如下锁表记录 二.解锁

for update造成的Oracle锁表与解锁

我遇到的情况: 当使用select语句查询表时,后面跟着for update , select * from table for update 当修改表中数据,但是没有commit就关掉PL/SQL,下次再打开,执行带for update的sql语句,就会卡死 一.锁表 查看锁表进程SQL语句: select * from v$session t1, v$locked_object t2 where t1.sid = t2.SESSION_ID; 如果有记录,可查到如下锁表记录 二.解锁 杀掉锁

Oracle锁表与解锁

查看锁表进程SQL语句 select * from v$session t1, v$locked_object t2 where t1.sid = t2.SESSION_ID; 解锁 杀掉锁表进程: 记录下SID和serial# ,分别替换掉下面的1155,39095,即可解除锁表 alter system kill session '1155,39095'; 原文地址:https://www.cnblogs.com/yx007/p/9077939.html

Oracle的锁表与解锁

Oracle的锁表与解锁 SELECT /*+ rule */ s.username, decode(l.type,'TM','TABLE LOCK', 'TX','ROW LOCK', NULL) LOCK_LEVEL, o.owner,o.object_name,o.object_type, s.sid,s.serial#,s.terminal,s.machine,s.program,s.osuser FROM v$session s,v$lock l,dba_objects o WHERE

oracle查看锁表进程,杀掉锁表进程

查看锁表进程SQL语句1: 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_