Oracle锁表及解锁

为了防止用户在同一时间并发地访问和修改资源,ORACLE使用不同类型的锁控制对数据的并发访问,以防止用户之间出现破坏性的交互操作

1,锁表

锁定表的通用语法:
lock table 表名 in <share or share update or exclusive mode>

共有三种锁表模式:

     共享模式(in share mode)

     共享更新模式(in share update mode)

     排他锁模式(in exclusive mode)

锁表实例:
//以排他锁模式锁定tRun表
lock table tRun in exclusive mode

2,查看某个表被锁定

查看被锁定的表:
select b.owner,b.object_name,a.session_id,a.locked_mode from v$locked_object a,dba_objects b 
where b.object_id = a.object_id

3,查询sid及serial#

查询sid及serial#
select b.username,b.sid,b.serial#,logon_time from v$locked_object a,v$session b 
where a.session_id = b.sid order by b.logon_time

4,删除锁

删除锁表:
//其中,159为sid;107为serial#
alter system kill session '159,107'
原文地址:https://www.cnblogs.com/boby-/p/4724768.html