SqlServer查询被锁住的表和解锁表
--1.查看被锁表 SELECT request_session_id as spid,OBJECT_NAME(resource_associated_entity_id) as tableName FROM sys.dm_tran_locks WHERE resource_type='OBJECT' --spid 锁表进程 ;tableName 被锁表名 --2.解锁 declare @spid int Set @spid = 被锁表的进程号 declare @sql varchar(1000) set @sql='kill '+cast(@spid as varchar) exec(@sql)
Oracle查询被锁住的表和解锁表
--1.锁表查询的代码有以下的形式: SELECT count(*) FROM v$locked_object; SELECT * FROM v$locked_object; --2.查看哪个表被锁 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; --3.查看是哪个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; --4.杀掉对应进程 alter system kill session'1025,41'; --其中1025为sid,41为serial#.
MySQL查询被锁住的表和解锁表
查看锁表语句 show OPEN TABLES where In_use > 0; 找到锁表的进程 show processlist; 删除锁表进程 kill 123;