动态性能视图是以V$为前缀
--锁表相关的五张表
SELECT * FROM v$locked_object;
SELECT * FROM v$session;
SELECT * FROM v$process;
SELECT * FROM all_objects;
SELECT * FROM v$sqlarea;
where a.tablespace_name=b.tablespace_name;
--查看锁表 主要字段
SELECT s.SID,l.SESSION_ID lock_session_id,s.SESSION_EDITION_ID,s.SERIAL#,p.PID,p.SPID,o.OBJECT_NAME,o.OBJECT_TYPE,s.MACHINE,s.CLIENT_INFO,s.LOGON_TIME,
l.OS_USER_NAME,s.OSUSER,s.AUDSID,s.USERNAME,s.COMMAND,s.STATUS,s.PROGRAM,
s.SQL_EXEC_START,s.PREV_EXEC_START,s.EVENT,s.P2TEXT,s.P3TEXT,s.WAIT_TIME,s.SECONDS_IN_WAIT,s.STATE,
q1.SQL_TEXT,q1.SQL_FULLTEXT,q1.LAST_ACTIVE_TIME,q2.SQL_TEXT prev_sql_text,q2.SQL_FULLTEXT prev_SQL_FULLTEXT,q2.LAST_ACTIVE_TIME prev_LAST_ACTIVE_TIME
FROM v$locked_object l
LEFT JOIN v$session s ON l.SESSION_ID=s.SID
LEFT JOIN v$process p ON p.ADDR=s.PADDR
LEFT JOIN all_objects o ON o.OBJECT_ID=l.OBJECT_ID
LEFT JOIN v$sqlarea q1 ON q1.SQL_ID = s.SQL_ID
LEFT JOIN v$sqlarea q2 ON q2.SQL_ID=s.PREV_SQL_ID
--查看会话 主要字段
SELECT s.SID,l.SESSION_ID lock_session_id,s.SESSION_EDITION_ID,s.SERIAL#,p.PID,p.SPID,o.OBJECT_NAME,o.OBJECT_TYPE,s.MACHINE,s.CLIENT_INFO,s.LOGON_TIME,
l.OS_USER_NAME,s.OSUSER,s.AUDSID,s.USERNAME,s.COMMAND,s.STATUS,s.PROGRAM,
s.SQL_EXEC_START,s.PREV_EXEC_START,s.EVENT,s.P2TEXT,s.P3TEXT,s.WAIT_TIME,s.SECONDS_IN_WAIT,s.STATE,
q1.SQL_TEXT,q1.SQL_FULLTEXT,q1.LAST_ACTIVE_TIME,q2.SQL_TEXT prev_sql_text,q2.SQL_FULLTEXT prev_SQL_FULLTEXT,q2.LAST_ACTIVE_TIME prev_LAST_ACTIVE_TIME
FROM v$session s
LEFT JOIN v$locked_object l ON l.SESSION_ID=s.SID
LEFT JOIN v$process p ON p.ADDR=s.PADDR
LEFT JOIN all_objects o ON o.OBJECT_ID=l.OBJECT_ID
LEFT JOIN v$sqlarea q1 ON q1.SQL_ID = s.SQL_ID
LEFT JOIN v$sqlarea q2 ON q2.SQL_ID=s.PREV_SQL_ID
ORDER BY machine,logon_time desc
-- 二、再查冻表情况
--查找冻表
select sid,seconds_in_wait,state,wait_time_micro from v$session_wait where event='library cache lock';
--1、在PL/SQL软件中分别用下列语句杀死冻表会话。100*mode+namespace -599 18516 06:02 -317 2886 10:04 -33 46427 14:04 SELECT SPARE4 FROM SYS.OPTSTAT_HIST_CONTROL$ WHERE SNAME = :B1
select * from v$session where sid =&sid
alter system kill session '&SID,&SERIAL#'
--2、如果杀不死,用下面方法
--2根据SID找出SPID
select spid, osuser, s.program
from v$session s,v$process p
where s.paddr=p.addr and s.sid=&sid
-- 再在LINUX下用kill -9 &spid语句杀。
张兴康 发表于 2017-1-6 14:02
此贴最后一个回复
欢迎光临 度量快速开发平台-专业、快速的软件定制快开平台 (http://bbs.delit.cn/) | Powered by Discuz! X3.2 |