解除Oracle被锁的表

1.开一个会话session1

SQL>select sid from v$mystat where rownum=1;

SID

158

SQL>create table t(x int primary key);

table created

SQL>insert into t values(1);

commit;

SQL>update t1 set    t=10 where  x=1;

2.再开一个会话

SQL>select sid from v$mystat where rowunm=1;

SID

157

SQL>update t1 se x=10 where x=1;

这个时候session2被session1锁住

3、执行以下语句查看是哪个进程和序列锁住了表

select sess.sid,

sess.serial#,

lo.oracle_username,

lo.os_user_name,

ao.object_name,

lo.locked_mode

from v$locked_object lo,

dba_objects ao,

v$session sess

where ao.object_id = lo.object_id and lo.session_id = sess.sid

4、执行下面的语句,将改锁表的进程和序列杀掉了

alter system kill session '1020,38953' --(1020,就是执行第一步语句得到的sid字段值,38953就是serial#字段值)

参考博文:http://www.cnblogs.com/srsee/archive/2013/05/10/infi0510_2.html

原文地址:http://blog.51cto.com/linux10000/2070177

时间: 2024-11-16 08:40:11

解除Oracle被锁的表的相关文章

查看oracle被锁的表

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; 查到的都是被锁的表 SELECT * FROM v$session where sid = xxx; 查到 serial# 最后alter system kill session 'sid,serial#';  关闭锁

查询oracle被锁的表及其如何释放

查询数据库中哪些表被锁定的sql语句 SELECT object_name, machine, s.sid, s.serial# FROM gv$locked_object l, dba_objects o, gv$session s WHERE l.object_id = o.object_id AND l.session_id = s.sid; --释放SESSION SQL: --alter system kill session 'sid, serial#'; ALTER system

oracle查看被锁的表及解除锁

-- 查看被锁对象 select object_name,machine,s.sid,s.serial# from v$locked_object l,dba_objects o ,v$session s where l.object_id = o.object_id and l.session_id=s.sid; --杀死进程 alter system kill session '24,111'; (其中24,111分别是上面查询出的sid,serial# ora-00031:session

Oracle的锁表与解锁

Oracle的锁表与解锁 SELECT /*+ rule */ s.username, decode(l.type,'TM','TABLE LOCK', 'TX','ROW LOCK', NULL) LOCK_LEVEL, o.owner,o.object_name,o.object_type, s.sid,s.serial#,s.terminal,s.machine,s.program,s.osuser FROM v$session s,v$lock l,dba_objects o WHERE

Oracle查询被锁的表及进程的方法

Oracle查询可以有多种方法,下面为您介绍的是如何Oracle查询被锁的表及Oracle查询连接的进程的方法,希望对您能够有所帮助. 一.查看被锁的表 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

oracle查看被锁的表和被锁的进程,杀掉进程

-- 1. 查看被锁的表 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 -- 2.

SqlServer 查看被锁的表和解除被锁的表

查看被锁的表 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 = 74 --锁表进程 declare @sql varchar(1000) set @sql='kill '+cast(@spid as va

对Oracle 并行的误解2--其实会锁全表

我一直以为Oracle只会锁住需要修改的数据,但在并行下是这样的,并行update是会锁全表的,下面的实验: session1: SQL> select sid from v$mystat where rownum=1; SID ---------- 11 SQL> select sid from v$mystat where rownum=1; SQL> create table test as select * from dba_objects; SQL> alter sess

oracle的行级锁与表级锁

1.在操作DML(create,insert,update)语句时,oracle会自动加上行级锁,在select * from table for update [of column][nowait|wait 3]时,oracle也会自动加锁 建议(1)一般在for update 时加nowait,这样就不用等待其他事务执行了,一判断有事务,立马抛出错误. 建议(2)一般的of column都是在多表操作的时候,能锁定其中一个表的某些列,如果还是同一张表的话,并不能锁定某些列 2.表级锁 表级锁