查看被锁的表: select l.session_id,o.owner,o.object_name from v$locked_object l,dba_objects o where l.object_id=o.object_id; 查看被锁表的serial: select t2.username,t2.sid,t2.serial#,t2.logon_time from v$locked_object t1,v$session t2 where t1.session_id=t2.sid ord…
--方法1WITH CTE_SID ( BSID, SID, sql_handle ) AS ( SELECT blocking_session_id , session_id , sql_handle FROM sys.dm_exec_requests UNION ALL SELECT A.blocking_session_id , A.session_id , A.sql_handle FROM sys.dm_exec_requests A JOIN CTE_SID B ON A.SESSI…
--1.查进程select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) tableNamefrom sys.dm_tran_locks where resource_type='OBJECT'order by request_session_id --2.查sql select er.session_id, CAST(csql.text AS varchar(2000)) AS CallingSQL fro…
查看别锁表 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 @spid = --锁表进程 declare @sql varchar() set @sql='kill '+cast(@spid as varchar) ex…
步骤1.查看锁表进程 2.杀死进程 --1.查询锁表进程 spid.和被锁表名称 tableName select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) tableName from sys.dm_tran_locks where resource_type='OBJECT' and OBJECT_NAME(resource_associated_entity_id) is not nu…
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='kil…
查看被锁表: 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 @sql='kill '+cast(@spid as varchar) exec(@sql…
--Oracle数据库操作中,我们有时会用到锁表查询以及解锁和kill进程等操作,那么这些操作是怎么实现的呢?本文我们主要就介绍一下这部分内容. --(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_objec…
--查看锁表: 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 @spid = 57 --锁表进程 declare @sql varchar(1000) set @sql='kill '+cast(@spid as va…
查看oracle的sql语句历史记录和锁表的情况 (2012-01-04 20:59:59) 转载▼ 标签: 杂谈 分类: database 查询sql的历史记录 select * from v$sqlarea t where t.PARSING_SCHEMA_NAME in ('用户名') order by t.LAST_ACTIVE_TIME descselect * from v$sqlarea t order by t.LAST_ACTIVE_TIME desc 查看一段时间内的执行情况…
查询所有数据库占用磁盘空间大小的SQL语句: 语句如下: select TABLE_SCHEMA, concat(truncate(sum(data_length)/1024/1024,2),' MB') as data_size, concat(truncate(sum(index_length)/1024/1024,2),'MB') as index_size from information_schema.tables group by TABLE_SCHEMA order by data…
查看被锁表: 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 @sql='kill '+cast(@spid as varchar) exec(@sql)…
1.不同数据库之间复制表的数据的方法: 当表目标表存在时: insert into 目的数据库..表 select * from 源数据库..表 当目标表不存在时: select * into 目的数据库..表 from 源数据库..表 2. 查看是否锁表 show OPEN TABLES where In_use > 0;…