USE mastergo CREATE PROCEDURE [dbo].[sp_who_lock]AS BEGIN DECLARE @spid INT , @bl INT , @intTransactionCountOnEntry INT , @intRowcount INT , @intCountProperties INT , @intCounter INT C
查询锁表进程: 1.查询是否锁表 show OPEN TABLES where In_use > 0; 2.查询进程 show processlist 查询到相对应的进程===然后 kill id 补充: 查看正在锁的事务 SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCKS; 查看等待锁的事务 SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS; 分析锁表原因: 参考:htt
查询锁表进程: 1.查询是否锁表 show OPEN TABLES where In_use > 0; 2.查询进程 show processlist 查询到相对应的进程===然后 kill id 补充: 查看正在锁的事务 SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCKS; 查看等待锁的事务 SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS; 分析锁表原因: 参考:htt
问题描述:只是单纯的执行了"select count(*) from 某表":数据表中只有一两条数据,能查询其他表,唯独这个表不能进行任何操作: 经百度搜索实验,发现应该是某个进程阻塞了,使用了一下代码进行的查询(这个比较详细): declare @spid int,@bl int ,blocked ) a ) b where a.blocked=spid) union )) + ' 进程号, 其执行的SQL 语法如下' else )))) +' 阻塞, 其当前进程执行的SQL 语法如
查询死锁进程和表 SELECT request_session_id AS spid , OBJECT_NAME(resource_associated_entity_id) AS 'table' FROM sys.dm_tran_locks WHERE resource_type = 'OBJECT'; 杀死进程 kill [SPID]
//////////////////查询指定表外键约束select a.name as 约束名, object_name(b.parent_object_id) as 外键表, d.name as 外键列, object_name(b.referenced_object_id) as 主健表, c.name as 主键列 from sys.foreign_keys A inner join sys.foreign_key_columns B on A.object_id=b.constraint
--SQL查询每个表的字段数量select b.[name], count(*) As AllCount,ISNULL(ISNULL(sum(case when isnullable=0 then 1 end),null),null) as NotNullCountfrom syscolumns aINNER JOIN( select [id], [name] from [sysobjects] where [type] = 'u' ) AS b ON a.id = b.[id] GROUP b
1.查询某个表被哪些存储过程(以下简称 SP)使用到 : select distinct object_name(id) from syscomments where id in (select object_id from sys.objects where type ='P') and text like'%TableName%' 2.查找那些过程对该表做了更新操作: select distinct object_name(id) from syscomments where id in (
-- 获得存储过程创建语句 select o.xtype,o.name,cm.text from syscomments cm inner join sysobjects o on o.id=cm.id where xtype ='p' order by o.xtype,o.name,cm.text -- 获得视图程创建语句 select o.xtype,o.name,cm.text from syscomments cm inner join sysobjects o on o.id=cm.i
◆Oracle查询用户表空间:select * from user_all_tables ◆Oracle查询所有函数和储存过程:select * from user_source ◆Oracle查询所有用户:select * from all_users.select * from dba_users ◆Oracle查看当前用户连接:select * from v$Session ◆Oracle查看当前用户权限:select * from session_privs ◆Oracle查看用户表空间
SQL语句查询某表的所有字段及数据类型 SELECT name AS column_name , TYPE_NAME(system_type_id) AS column_type , max_length , is_nullable FROM sys.columns WHERE object_id = OBJECT_ID(N'customerbase') --customerbase 为表名
-- 获得存储过程创建语句 select o.xtype,o.name,cm.text from syscomments cm inner join sysobjects o on o.id=cm.id where xtype ='p' order by o.xtype,o.name,cm.text -- 获得视图程创建语句 select o.xtype,o.name,cm.text from syscomments cm inner join sysobjects o on o.id=cm.i
例1:查询某个文章及其对应的评论(单个详情) ) FROM A; 例2:查询分类表中,每种分类各包含多少商品(汇总) SELECT category_id, (SELECT count(goods_id) FROM Goods WHERE category_id = A.category_id) FROM category; 部分参考:http://zhidao.baidu.com/link?url=FAZU7UHkC-qZXm4rPm5SNzHtVPf_YzINFsM-sNIeVSXungAt
--1.查询某个表被哪些存储过程使用到 : select distinct object_name(id) from syscomments where id in (select object_id from sys.objects where type ='P') and text like'%TableName%' --2.查找那些过程对该表做了更新操作: select distinct object_name(id) from syscomments where id in(select