使用SQL获取ASH/ADDM/AWR报告
有时候想直接在SQLPLUS中看ASH/ADDM/AWR报告,用下面方法还是比较方便,
因为AWR数据在数据库中默认只保留7天,即使设置保留30天,可能有时候我们需要
进行性能对比分析需要保留时段之前的AWR,那么我们可以采用脚本定时将AWR报告
输出保存。
获取ASH报告
select output
from table(dbms_workload_repository.ash_report_text((select dbid from v$database),
1,
TO_DATE('20130712203500',
'YYYYMMDDHH24MISS'),
TO_DATE('20130712204600',
'YYYYMMDDHH24MISS')));
获取ADDM报告
select * from dba_advisor_tasks s order by s.created desc
set long 1000000 pagesize 0 longchunksize 1000
select dbms_advisor.get_task_report('ADDM:3620614489_1_25298') from dual;
获取AWR报告
SELECT SNAP_ID snapid FROM DBA_HIST_SNAPSHOT;
select output from
table(dbms_workload_repository.awr_report_text(
&dbid,
&inst_num,
&bid, &eid,
8 ));