select l.spid, locktype=convert(char(12),name), dbname=convert(char(15),db_name(l.dbid)), 'table'=convert(char(15),object_name(l.id,l.dbid)), page, class=convert(char(15),class), hostname, cmd from master..syslocks l,master..spt_values v,master..sysprocesses p where l.type = v.number and v.type = 'L' and l.spid = p.spid order by spid
sp_who 查看锁表情况
sp_lock 查看被锁的表的id号
dbcc traceon(3604)
dbcc sqltext(pid) 查看pid相关的sql 需要sa权限
注意:执行dbcc sqltext()之前需要先执行dbcc traceon(3604)
set showplan on 查看sql执行计划
set statistics time on 查看sql执行时间
select p.spid,a.serial#, c.object_name,b.session_id,b.oracle_username,b.os_user_name from v$process p,v$session a, v$locked_object b ,all_objects c where p.addr=a.paddr and a.process=b.process and c.object_id=b.object_id ;