-- 整体 undo 使用情况
select b.tablespace_name,
nvl(used_undo, 0) "USED_UNDO(M)",
total_undo "Total_undo(M)",
trunc(nvl(used_undo, 0) / total_undo * 100, 2) used_PCT
from (select nvl(sum(bytes / 1024 / 1024), 0) used_undo, tablespace_name
from dba_undo_extents
where status in ('ACTIVE', 'UNEXPIRED')
and tablespace_name in
(select value from v$parameter where name = 'undo_tablespace')
group by tablespace_name) a,
(select tablespace_name, sum(bytes / 1024 / 1024) total_undo
from dba_data_files
where tablespace_name in
(select value from v$parameter where name = 'undo_tablespace')
group by tablespace_name) b
where a.tablespace_name(+) = b.tablespace_name;
-- 各状态 undo 使用情况统计
select tablespace_name,status,sum(bytes)/1024/1024 MB from dba_undo_extents
where tablespace_name like 'UNDOTBS%'
group by tablespace_name,status
order by 1;
======
select tablespace_name, status, sum(bytes/1024/1024) "MB"
from dba_undo_extents
group by tablespace_name, status
order by 1, 2
========
--UNDO 使用率
select AA.TABLESPACE_NAME,
ROUND((nvl(BB.UNEXPIRED_USED_GB, 0) + nvl(BB.ACTIVE_USED_GB, 0)) /
AA.TOTAL_GB * 100,
2) USED_PCT,
ROUND(nvl(BB.ACTIVE_USED_GB, 0) / AA.TOTAL_GB * 100, 2) PCT_ACTIVE,
ROUND(nvl(BB.UNEXPIRED_USED_GB, 0) / AA.TOTAL_GB * 100, 2) PCT_UNEXPIRED,
ROUND(nvl(BB.EXPIRED_USED_GB, 0) / AA.TOTAL_GB * 100, 2) PCT_EXPIRED,
maxquerylen,
tuned_undoretention,
pct_retention,
AA.TOTAL_GB,
nvl(BB.ACTIVE_USED_GB, 0) ACTIVE_USED_GB,
nvl(BB.UNEXPIRED_USED_GB, 0) UNEXPIRED_USED_GB,
nvl(BB.EXPIRED_USED_GB, 0) EXPIRED_USED_GB,
nvl(BB.ACTIVE_EXTENT_CNT, 0) ACTIVE_EXTENT_CNT,
nvl(BB.UNEXPIRED_EXTENT_CNT, 0) UNEXPIRED_EXTENT_CNT,
nvl(BB.EXPIRED_EXTENT_CNT, 0) EXPIRED_EXTENT_CNT
from (select tablespace_name, sum(bytes) / 1024 / 1024 / 1024 TOTAL_GB
from DBA_DATA_FILES
where tablespace_name IN ('UNDOTBS2', 'UNDOTBS1')
评论