当前位置: 代码迷 >> 综合 >> Oracle 使用SQL生成AWR报告
  详细解决方案

Oracle 使用SQL生成AWR报告

热度:91   发布时间:2024-01-16 02:20:28.0
有些时候会使用sql生成AWR报告 ,其实也是非常的方便。

首先获取数据库和快照的基本信息后续使用。
select dbid from v$database;
select  * from dba_hist_snapshot order by snap_id desc;                                                      

1.生成文本AWR报告
sqlplus / as sysdba

Set linesize 201 pagesize 0
Col output format a200

Spool /tmp/awr_text.text

select output
from table(dbms_workload_repository.awr_report_text(l_dbid     => 1642013397,
l_bid      => 1150,--开始快照ID
l_eid      => 1151,--结束快照ID
l_inst_num => 1));

Spool off


2.生成HTML AWR报告,建议使用,结构更加清晰,使用浏览器打开
sqlplus / as sysdba

Set linesize 2001 pagesize 0
Col output format a2000
Set term off

Spool /tmp/awr_html.html

select output
from table(dbms_workload_repository.awr_report_html(l_dbid     => 1642013397,
l_bid      => 1150,
l_eid      => 1151,
l_inst_num => 1));

Spool off
Set term on