VARIABLE rpt_options NUMBER;
DEFINE no_options = 0;
define ENABLE_ADDM = 8;
REM according to your needs, the value can be 'text' or 'html'
DEFINE report_type='html';
BEGIN
:rpt_options := &no_options;
END;
/
VARIABLE dbid NUMBER;
VARIABLE inst_num NUMBER;
VARIABLE bid NUMBER;
VARIABLE eid NUMBER;
BEGIN
SELECT MIN (snap_id) INTO :bid
FROM dba_hist_snapshot
WHERE TO_CHAR (end_interval_time, 'yyyymmdd') = TO_CHAR (SYSDATE-1, 'yyyymmdd');
SELECT MAX (snap_id) INTO :eid FROM dba_hist_snapshot WHERE TO_CHAR (begin_interval_time,'yyyymmdd') = TO_CHAR (SYSDATE-1, 'yyyymmdd');
SELECT dbid INTO :dbid FROM v$database;
SELECT instance_number INTO :inst_num FROM v$instance;
END;
/
COLUMN ext NEW_VALUE ext NOPRINT
COLUMN fn_name NEW_VALUE fn_name NOPRINT;
COLUMN lnsz NEW_VALUE lnsz NOPRINT;
SELECT 'txt' ext
FROM DUAL
WHERE LOWER ('&report_type') = 'text';
SELECT 'html' ext
FROM DUAL
WHERE LOWER ('&report_type') = 'html';
SELECT 'awr_report_text' fn_name
FROM DUAL
WHERE LOWER ('&report_type') = 'text';
SELECT 'awr_report_html' fn_name
FROM DUAL
WHERE LOWER ('&report_type') = 'html';
SELECT '80' lnsz
FROM DUAL
WHERE LOWER ('&report_type') = 'text';
SELECT '1500' lnsz
FROM DUAL
WHERE LOWER ('&report_type') = 'html';
set linesize &lnsz;
COLUMN report_name NEW_VALUE report_name NOPRINT;
SELECT instance_name || '_awrrpt_' || instance_number || '_' || b.timestamp || '.' || '&ext' report_name FROM v$instance a,(SELECT TO_CHAR(begin_interval_time,'yyyymmdd') timestamp FROM dba_hist_snapshot WHERE snap_id = :eid) b;
SET TERMOUT OFF;
SPOOL $AWR_DIR/&report_name;
SELECT output
FROM TABLE (DBMS_WORKLOAD_REPOSITORY.&fn_name (:dbid,
:inst_num,
:bid,
:eid,
:rpt_options));
SPOOL OFF;
SET TERMOUT ON;
CLEAR COLUMNS SQL;
TTITLE OFF;
BTITLE OFF;
REPFOOTER OFF;
UNDEFINE report_name
UNDEFINE report_type
UNDEFINE fn_name
UNDEFINE lnsz
UNDEFINE no_options
AWR脚本
原创
©著作权归作者所有:来自51CTO博客作者数字化咨询顾问的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:Oracle ASM
下一篇:SQLServer大内存设置建议
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Oracle Statspack 和 AWR 生成 脚本
<br /> <br /> <br /> Oracle Statspack 和AWR 是我们分析DB 的2个重要工具
oracle report 脚本 聊天 工具 -
awr 积累
AWR
AWR