表解锁

1 查出被锁的表信息

SELECT /*+ rule*/

a.sid, b.owner, object_name, object_type

FROM v$lock a, all_objects b

WHERE TYPE = ‘TM‘

and a.id1 = b.object_id;

--1.查出锁定object的session的信息以及被锁定的object名

SELECT l.session_id sid, s.serial#, l.locked_mode,l.oracle_username,

l.os_user_name,s.machine, s.terminal, o.object_name, s.logon_time

FROM v$locked_object l, all_objects o, v$session s

WHERE l.object_id = o.object_id

AND l.session_id = s.sid

ORDER BY sid, s.serial# ;

--2.查出锁定表的session的sid, serial#,os_user_name, machine name, terminal和执行的语句

--比上面那段多出sql_text和action

SELECT l.session_id sid, s.serial#, l.locked_mode, l.oracle_username, s.user#,

l.os_user_name,s.machine, s.terminal,a.sql_text, a.action

FROM v$sqlarea a,v$session s, v$locked_object l

WHERE l.session_id = s.sid

AND s.prev_sql_addr = a.address

ORDER BY sid, s.serial#;

--3.查出锁定表的sid, serial#,os_user_name, machine_name, terminal,锁的type,mode

SELECT s.sid, s.serial#, s.username, s.schemaname, s.osuser, s.process, s.machine,

s.terminal, s.logon_time, l.type

FROM v$session s, v$lock l

WHERE s.sid = l.sid

AND s.username IS NOT NULL

ORDER BY sid;

2 查出serial

SELECT sid,serial# FROM v$session WHERE sid = 662;

3 杀掉session

alter system kill session ‘662,44825‘;

SELECT ‘alter system kill session ‘‘‘||sid||‘,‘||serial#||‘‘‘;‘ FROM v$session WHERE username=‘DCDB‘;

4 查出是否有长时间执行的SQL

select a.sid, b.sql_text

from v$session a, v$sqlarea b

where a.sql_hash_value = b.hash_value

and a.sid in

(SELECT SID from GV$Session_longops where TIME_REMAINING > 0);

时间: 2024-10-11 16:52:54

表解锁的相关文章

SQL 单用户 锁表 解锁

USE master; GO DECLARE @SQL VARCHAR(MAX); SET @SQL='' SELECT @[email protected]+'; KILL '+RTRIM(SPID) FROM sysprocesses WHERE dbid=DB_ID('WMS.MDF'); EXEC(@SQL); GO ALTER DATABASE [WMS.MDF] SET MULTI_USER; 查看被锁表: select   request_session_id   spid,OBJ

Oracle表解锁语句

如果你发现无法对一个表进行修改.删除等操作时,你可以利用以下语句查询是否是该表被锁住了 --查询锁select sess.sid,sess.serial#, lo.oracle_username,lo.os_user_name,ao.object_name,lo.locked_modefrom v$locked_object lo,dba_objects ao,v$session sesswhere ao.object_id = lo.object_idand lo.session_id = s

Oracle表解锁

网搜 --第一步 查看被锁表 select b.owner,b.object_name, b.object_id,l.session_id,l.locked_mode from v$locked_object l, dba_objects b where b.object_id=l.object_id; --第二步 select do.object_id ,do.object_name from dba_objects do where do.OWNER='ISTAUDIT' and do.ob

mysql查看锁表解锁

-- 查看那些表锁到了 show OPEN TABLES where In_use > 0; -- 查看进程号 show processlist; -- 删除进程 kill 1085850;

DB2如何将数据库表解锁

在DB2的命令行中输入:  update monitor switches using lock on table on  然后打开另一个DB2命令窗口执行我的那个被吊死的Update语句.  然后在第一个DB2命令窗口执行: [@[email protected]]get snapshot for locks on Database_Name(你的数据库的名字)> locks.TXT 然后,可以看到第一个DB2的窗口有一个信息输出,把这些信息输出到TXT中,大致如下: 应用程序句柄 = 36 

数据库表解锁

1.查询表锁 SELECT a.sid,a.serial#,a.username,a.program,b.os_user_name,c.object_name FROM v$session a,v$locked_object b,dba_objects c where b.session_id = a.sid and c.object_id = b.object_id order by a.logon_time; 2.解锁 alter system kill session'1025,41';

oracle查询锁表解锁语句 (转)

原文地址:http://blog.csdn.net/zhldt2008/article/details/7953932 1. 如下语句 查询锁定的表: SELECT l.session_id sid, s.serial#, l.locked_mode,l.oracle_username, l.os_user_name,s.machine, s.terminal, o.object_name, s.logon_time FROM v$locked_object l, all_objects o,

oracle锁表解锁

select substr(object_name,1,30),substr(os_user_name,1,20) from v$locked_object,user_objects where v$locked_object.object_id = user_objects.object_id select b.owner,b.object_name,a.session_id,a.locked_modefrom v$locked_object a,dba_objects bwhere b.ob

mysql 查看锁表解锁

show OPEN TABLES where In_use > 0;-- 查看进程号show processlist;--删除进程 kill 1085850: 原文地址:https://www.cnblogs.com/Struts-pring/p/9733280.html