我写了一个PIVOT查询来获取过去15天的系统和sysaux表空间增长。查询没有给我一个正确的输出。它用E显示数字。我的企业管理器verison在13C中,存储库db版本是12.1.0.2。如果有人可以帮助我,我将不胜感激。可能是我在转换为GB时犯了错误。请帮忙。
with pivot_data AS (
select target_name, key_value, to_char(rollup_timestamp,'mm/dd/yy')as DT, average
from sysman.mgmt$metric_daily
where target_TYPE in ('rac_database') AND KEY_VALUE in ('SYSTEM','SYSAUX') AND TARGET_NAME IN ('DBKUH','ETPUZ','ZLDFK')
and column_label = 'Tablespace Used Space (MB)'
and trunc(rollup_timestamp) >= trunc(sysdate)-15)
select * from pivot_data
pivot
( sum(average/1024/1024/1024)
for TARGET_NAME
in ( 'DBKUH' AS ETPUZ,'ETPUZ' AS ETPUZ,'ZLDFK' AS ZLDFK )
)
order by DT
/
答案 0 :(得分:0)
您正在使用标有'Tablespace Used Space(MB)'
的列的平均值。我冒昧地猜测它的大小以MB为单位,所以要转换为GB,你应该只划分1024次。
我注意到的其他事情:
'DBKUH' as ETPUZ
还是这是一个错字?trunc(timestamp) >= trunc(sysdate)-15
是等效的
到timestamp >= ...
,后者将允许您使用索引
在timestamp
而前者不会。