zbb20170728 oracle 查看被锁对象

 查询Oracle正在执行和执行过的SQL语句

--查询Oracle正在执行的sql语句及执行该语句的用户

SELECT b.sid oracleID,
       b.username 登录Oracle用户名,
       b.serial#,
       spid 操作系统ID,
       paddr,
       sql_text 正在执行的SQL,
       b.machine 计算机名
FROM v$process a, v$session b, v$sqlarea c
WHERE a.addr = b.paddr
   AND b.sql_hash_value = c.hash_value

--查看正在执行sql的发起者的发放程序

SELECT OSUSER 电脑登录身份,
       PROGRAM 发起请求的程序,
       USERNAME 登录系统的用户名,
       SCHEMANAME,
       B.Cpu_Time 花费cpu的时间,
       STATUS,
       B.SQL_TEXT 执行的sql
FROM V$SESSION A
LEFT JOIN V$SQL B ON A.SQL_ADDRESS = B.ADDRESS
                   AND A.SQL_HASH_VALUE = B.HASH_VALUE
ORDER BY b.cpu_time DESC

--查出oracle当前的被锁对象

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#;

--kill掉当前的锁对象可以为

alter system kill session ‘sid, s.serial#‘;

select * from v$access o where o.OBJECT like ‘XXWPF007%‘ --查找正在运行的对象,获取sid
select a.serial# from v$session a WHERE A.SID=sid  --通过sid 获取serial#
alter system kill session ‘sid,serial#‘ --eg: alter system kill session ‘123,3211‘

SELECT * FROM V$DB_OBJECT_CACHE WHERE name=‘CUX_OE_ORDER_RPT_PKG‘ AND LOCKS!=‘0‘;

SELECT sn.username,M.SID,sn.SERIAL#,M.TYPE,
  DECODE(M.lmode,0,‘None‘,1,‘Null‘,2,‘Row Share‘,3,‘Row Excl.‘,4,‘Share‘, 5,‘S/Row Excl.‘,6,‘Exclusive‘,lmode,
  LTRIM(TO_CHAR(lmode, ‘990‘))) lmode,
  DECODE(M.request, 0,‘None‘,1, ‘Null‘, 2,‘Row Share‘, 3,‘Row Excl.‘,4,‘Share‘, 5,‘S/Row Excl.‘,6,‘Exclusive‘,request,
  LTRIM(TO_CHAR(M. request, ‘990‘))) request,M.id1,M.id2
  FROM v$session sn, v$lock M
  WHERE (sn.SID = M.SID AND M.request != 0)
    OR (sn.SID = M.SID AND M.request = 0 AND lmode != 4
    AND (id1, id2) IN (SELECT s.id1, s.id2
                            FROM v$lock s
                            WHERE request != 0
                            AND s.id1 = M.id1
                            AND s.id2 = M.id2))
 ORDER BY id1, id2, M.request;
kill 所有占用资源的会话
命令形式:alter system kill session ‘sid,serial#‘;
占用test_1的资源的会话:
alter system kill session ‘158,15184‘;
时间: 2024-10-12 23:29:51

zbb20170728 oracle 查看被锁对象的相关文章

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查看被锁的表和被锁的进程,杀掉进程

-- 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.

oracle查看被锁的表和解锁

--以下几个为相关表SELECT * FROM v$lock;SELECT * FROM v$sqlarea;SELECT * FROM v$session;SELECT * FROM v$process ;SELECT * FROM v$locked_object;SELECT * FROM all_objects;SELECT * FROM v$session_wait; --查看被锁的表select b.owner,b.object_name,a.session_id,a.locked_m

170308、oracle查看被锁的表和解锁

--以下几个为相关表SELECT * FROM v$lock;SELECT * FROM v$sqlarea;SELECT * FROM v$session;SELECT * FROM v$process ;SELECT * FROM v$locked_object;SELECT * FROM all_objects;SELECT * FROM v$session_wait; --查看被锁的表 select b.owner,b.object_name,a.session_id,a.locked_

Oracle查看有锁进程,删除锁

查看锁表进程SQL语句1: 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_

ORACLE查看数据文件包含哪些对象

在上篇ORACLE查看表空间对象中,我介绍了如何查询一个表空间有那些数据库对象,那么我们是否可以某个数据文件包含那些数据库对象呢?如下所示 SELECT  E.SEGMENT_TYPE          AS SEGMENT_TYPE       , E.SEGMENT_NAME          AS SEGMENT_NAME       , F.FILE_NAME             AS FILE_NAME       , SUM(E.BYTES)/1024/1024  AS SEGM

查看Oracle数据库被锁住的表,删除锁表的进程

锁表处理及查询 查看Oracle数据库被锁住的表,删除锁表的进程 1.查看被锁住的表 SELECT dob.object_name table_name,    lo.locked_mode, lo.session_id, vss.serial#, vss.action action, vss.osuser osuser, vss.logon_time, vss.process ap_pid, vps.spid db_pid FROM v$locked_object lo, dba_object

oracle 查看锁表情况与解表

oracle 查看锁表情况与解表 CreateTime--2018年4月27日17:24:37 Author:Marydon 1.锁表查询 --锁表查询 SELECT OBJECT_NAME AS TABLE_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; 2.

1.Oracle数据库查看用户锁表和对表解锁的sql语句

① 查看用户锁表 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 ② 解锁语句 alter system kil