Oracle 库常见问题排查
查询数据库的相关信息
查看正在执行的语句
SELECT s.sid, s.serial
FROM v$session s
JOIN v$sql sq ON s.sql_id = sq.sql_id
WHERE s.status = 'ACTIVE';
杀掉正在执行的sql
alter system kill session '7114,14991'
查看未提交的事务
SELECT S.SID
,S.SERIAL
,S.USERNAME
,S.OSUSER
,S.PROGRAM
,S.EVENT
,TO_CHAR(S.LOGON_TIME,'YYYY-MM-DD HH24:MI:SS')
,TO_CHAR(T.START_DATE,'YYYY-MM-DD HH24:MI:SS')
,S.LAST_CALL_ET
,S.BLOCKING_SESSION
,S.STATUS
,(
SELECT Q.SQL_TEXT
FROM V$SQL Q
WHERE Q.LAST_ACTIVE_TIME=T.START_DATE
AND ROWNUM<=1) AS SQL_TEXT
FROM V$SESSION S,
V$TRANSACTION T
WHERE S.SADDR = T.SES_ADDR;
查看锁表
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;