活跃会话:select sid,serial#,username,program,machine,status from v$session where status=‘ACTIVE’;
负载与SQL
正在运行的SQL(含等待):col inst_sid heading “INST_ID|:SID” format a7 …(按示例脚本输出 inst_id、sid、sql_id、sql_text、event、wait_sec 等)。
存储与空间
表空间使用率:select f.tablespace_name, a.total, f.free, round((f.free/a.total)*100,2) “% Free” from (select tablespace_name,sum(bytes/1024/1024) total from dba_data_files group by tablespace_name) a, (select tablespace_name,sum(bytes/1024/1024) free from dba_free_space group by tablespace_name) f where a.tablespace_name=f.tablespace_name(+) order by “% Free”;
缓存与日志
缓冲区命中率:select a.value+b.value logical_reads, c.value phys_reads, round(100*(1-c.value/(a.value+b.value)),4) hit_ratio from v$sysstat a,v$sysstat b,v$sysstat c where a.name=‘db block gets’ and b.name=‘consistent gets’ and c.name=‘physical reads’;
共享池命中率:select sum(pinhits)/sum(pins)*100 from v$librarycache;
日志缓冲区:select name,value from v$sysstat where name in (‘redo entries’,‘redo buffer allocation retries’);
这些SQL覆盖会话、SQL、空间、缓存与日志等核心维度,适合纳入巡检与告警。