oracle锁表查询

--1、查看被锁的表:   
--select t2.username,t2.sid,t2.serial#,t2.logon_time from
--v$locked_object t1,v$session t2 where t1.session_id=t2.sid
--order by t2.logon_time

select sess.sid, 
    sess.serial#, 
    lo.oracle_username, 
    lo.os_user_name, 
    ao.object_name, 
    lo.locked_mode,
    sess.machine,
    sess.terminal,
    sess.logon_time 
from v$locked_object lo, 
    dba_objects ao, 
    v$session sess 
where ao.object_id = lo.object_id and lo.session_id = sess.sid; 
    
--2、解锁:   
alter system kill session '2703,15149'; 
--sid,serial#是上面查询出来的

--连接操作系统杀掉进行
--查出session的spid
select spid, osuser, s.program
from v$session s, v$process p
where s.paddr = p.addr
and s.sid =149;

--kill -9 上一步查出来的spid

--杀掉线程
--orakill ZHYGYY 4732

--pdate pt_yppm_mz set areacode = '440406' where hospcode = '45592731244040411C2101' ;


你可能感兴趣的:(锁表,sql,oracle)