SQL查看表锁定,死锁解锁】的更多相关文章

select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) tableName from sys.dm_tran_locks where resource_type='OBJECT' declare @spid int --锁表进程 ) set @sql='kill '+cast(@spid as varchar) exec(@sql)…
2010年10月13日 12:46 来源:部松昌的博客 作者:部松昌 编辑:胡铭娅 一: 下面以AdventureWorks2008为示例数据库做简要的说明,过滤掉一般的数据库的共享锁, 作为示例必须要看到锁, 所以用WITH(HOLDLOCK)来保持锁. 1. Shared locks (S) 共享锁 USE AdventureWorks2008 BEGIN TRAN select * from Sales.SalesOrderHeader WITH(HOLDLOCK) ' SELECT re…
我自己的数据库表记录死锁后的 根据以下资料的 解决方案: 1. 先根据以下语句 查询 哪些表被 死锁,及 死锁的  spid SELECT request_session_id spid,OBJECT_NAME(resource_associated_entity_id)tableName FROM sys.dm_tran_locks WHERE resource_type='OBJECT ' 2. 再根据以上 语句查询出来的 spid 通过以下存储过程 查询是哪台机客户机 在操作,造成的死锁…
sqlserver 查看表结构 exec sp_help @TableName --得到表信息.字段,索引.constraint. exec sp_pkeys @TableName --得到主键. exec sp_fkeys @TableName --得到表的外键 exec sp_primarykeys @table_server --得到远程表主键. -- 查看某個表的索引 SELECT * FROM sys.sysindexes WHERE id=object_id('RelactionGr…
查询出来 select        request_session_id spid,       OBJECT_NAME(resource_associated_entity_id) tableName    from        sys.dm_tran_locks   where        resource_type='OBJECT 杀死死锁进程 kill spid 另: exec master.dbo.sp_who_lock --查看当前死锁进程 exec master.dbo.p_…
1,查看那个表死锁 select object_name(resource_associated_entity_id) as tableName, request_session_id as pid from sys.dm_tran_locks where resource_type = 'OBJECT' 2,结束死锁的进程 kill 70…
--kill session语句 1 alter system kill SESSION '2171,60490'; --以下几个为相关表 1 2 3 4 5 6 7 SELECT * FROM v$lock; SELECT * FROM v$sqlarea; SELECT * FROM v$session; SELECT * FROM v$process ; SELECT * FROM v$locked_object; SELECT * FROM all_objects; SELECT * F…
select a.name as 表名,max(b.rows) as 记录条数 from sysobjects a ,sysindexes b where a.id=b.id and a.xtype='u' group by a.name order by max(b.rows) desc 当如果使用子查询对上面语句做求和方法时会报下面错误: 除非另外还指定了 TOP 或 FOR XML,否则,ORDER BY 子句在视图.内联函数.派生表.子查询和公用表表达式中无效. 只要我们在嵌套子查询视图…
select a.name,b.name from sys.columns as a join sys.types as b on a.system_type_id=b.system_type_id where object_id=(select object_id from sys.tables where name='c_PROJECT')…
oracle: SELECT A.TABLE_NAME,A.COMMENTS,B.COLUMN_NAME,B.COMMENTS FROM USER_TAB_COMMENTS A,USER_COL_COMMENTS B WHERE A.TABLE_NAME=B.TABLE_NAME and a.table_name=' SYS_TIME' sqlserver2000: select sc.name as columnName,sp.value as remarks from sysobjects…