1、查询死锁数量
bash
SELECT COUNT(*) FROM V$LOCK WHERE BLOCKED = 1
2、查询慢SQL
bash
SELECT TOP 10 SQL_ID sqlId,SUBSTR(SQL_TEXT,1,100) sqlText,EXEC_TIME execTime,FINISH_TIME finishTime,N_RUNS nRuns
FROM V$LONG_EXEC_SQLS
WHERE FINISH_TIME > '2024-10-12 10:23:12'
ORDER BY FINISH_TIME DESC;
3、查询失败作业:24小时内
bash
SELECT NAME name,START_TIME startTime,END_TIME endTime,ERRCODE errCode,ERRINFO errInfo,JOBID jobId
FROM SYSJOB.SYSJOBHISTORIES2
WHERE START_TIME > '2024-08-15 10:23:12'
AND ERRCODE <> 0
4、检查点状态:10分钟未刷新时间
bash
SELECT
DATEDIFF(SECOND, LAST_END_TIME, CURRENT_TIMESTAMP) DURATION
from V$CKPT
5、时间偏移=系统时间-数据库时间
select to_char(sysdate,'yyyy-MM-dd HH24:mi:ss') from dual
6、长事务
select count(*) from V$SESSIONS where state = 'ACTIVE' and DATEDIFF(SECOND, LAST_SEND_TIME, CURRENT_TIMESTAMP) > 60
7、查询缓存区命中率
select name, Round(sum(rat_hit) /count(*),2) * 100 rat_hit
from v$bufferpool
WHERE name in ('NORMAL','KEEP')
group by name