oracle中可以使用sqlplus的set markup html ,生成html格式的报告,虽然一些css样式可以从awr报告的源代码中获得,但是一直想模拟awr报告那种隔行换色的效果一直没找到简易的方法来弄,尤其像我这种不会html编程的,今天才知道js可以放在body里,总算解决了一个我长久以来的困扰,以下是一个生产最近24小时awr报告index的html页面,有这个模板,基本上只要把sql语句往里扔就可以生成一个山寨awr样式的报告了。

set linesize 200
set term off verify off feedback off pagesize 999
rem set markup html on entmap ON spool on preformat off
set trims on;

COLUMN instname NEW_VALUE _instname NOPRINT
select instance_name instname from v$instance;
COLUMN indextime NEW_VALUE _indextime NOPRINT
select to_char(sysdate,'YYYY-MM-DD HH24:MI:SS') indextime from dual;
COLUMN rname NEW_VALUE _rname NOPRINT
select instance_name||'_awr_' rname from v$instance;

set heading on
set markup html on spool on preformat off entmap on -
head " -
  " -
body   "BGCOLOR='#0066CC'" -
table  "WIDTH='600px' BORDER='1' id='tab1'"

spool /check/awr/index.html
set markup html on entmap off

prompt



select
snap_id,
'&_rname.'||to_char(end_interval_time,'yyyymmdd_hh24mi')||'.html ' report,
to_char(begin_interval_time,'YYYY-MM-DD HH24:MI') begin_time ,
to_char(end_interval_time,'YYYY-MM-DD HH24:MI') end_time
from
(
select * from dba_hist_snapshot
order by snap_id desc
)
where rownum


prompt End of Report

prompt
spool off
SET MARKUP HTML OFF
SET TERMOUT ON
prompt
EXIT;

12-30 05:10