oracle sqlplus中使用spool生成美化的html网页
oracle sqlplus中使用spool生成美化的html网页
久违的太阳 2020-02-17 19:36:43 108 收藏
展开
set termout off --显示脚本中的命令执行结果,默认为on
set echo off --现实脚本中的命令,默认为on
set feedback off --现实脚本中执行返回的条数,默认为on
set heading off --输出域标题,默认为on
set verify off --可以关闭和打开提示确认信息old 1和new 1的显示
set wrap on --查询返回的纪录每行超过默认宽度时,可选择换行on 或不换行off,默认为换行;
set trimspool on --去除重定向spool输出每行的拖尾空格,缺省为off
set serveroutput on
set escape on
--下面是给在sqlplus中定义变量.例如文件名
define filename=dsg_dbcollect_
--下面是将别名赋予给变量,使用&来调用变量
COLUMN DGMODE NEW_VALUE DGMODE NOPRINT
select count(*) DGMODE from v$archive_dest where target = 'STANDBY';
--使用下面的格式,生成美化后的html.可以不设置head格式,使用默认的格式.但是如果想修改title,就需要使用head格式,如下:
set heading on
--不使用head格式直接用下面的:
set markup html on spool on preformat off entmap off
--设置head格式使用下面的:
set markup html on spool on preformat off entmap off -
head "-
<style type='text/css'> -
body {font:10pt Arial,Helvetica,sans-serif; color:black; background:White;} -
p {font:10pt Arial,Helvetica,sans-serif; color:black; background:White;} -
table,tr,td {font:10pt Arial,Helvetica,sans-serif; -
color:Black; background:#f7f7e7; padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;} -
th {font:bold 10pt Arial,Helvetica,sans-serif; color:#336699; background:#cccc99; padding:0px 0px 0px 0px;} -
h1 {font:16pt Arial,Helvetica,Geneva,sans-serif; color:#336699; background-color:White; border-bottom:1px solid #cccc99; margin-top:0pt; margin-bottom:0pt; padding:0px 0px 0px 0px;-} -
h2 {font:bold 10pt Arial,Helvetica,Geneva,sans-serif; color:#336699; background-color:White; margin-top:4pt; margin-bottom:0pt;} -
a {font:9pt Arial,Helvetica,sans-serif; color:#663300; background:#ffffff; margin-top:0pt; margin-bottom:0pt; vertical-align:top;} -
</style> -
<title>Report_For_DSG</title>" -
BODY "TEXT='#FF00Ff'" -
TABLE "WIDTH='90%' BORDER='1'"
alter session set nls_date_format='YYYY-MM-DD HH24:MI:SS';
--下面是spool调用变量
spool &filename&OPERTIME
set markup html on entmap off
具体格式:
--生成索引:
prompt <a class="link" href="#Initialization Parameter"><li><b>Initialization Parameter</b></li></a>
--生成一级标题:
prompt <a name="report"></a>
prompt <font size="+3" face="Arial,Helvetica,Geneva,sans-serif" color="#336699"><b>ORACLE REPORT FOR DSG</b></font><hr align="left" width="460">
--生成二级标题
--------------------------------------------------------# 3
----------------------------tablespace and datafile
--------------------------------------------------------
prompt <a name="report"></a>
prompt <font size="+2" face="Arial,Helvetica,Geneva,sans-serif" color="#336699"><b>ORACLE REPORT FOR DSG</b></font><hr align="left" width="460">
CLEAR COLUMNS BREAKS COMPUTES
--生成三级标题
--------------------------------------------------------## 3.1
----------------------------tablespace and datafile
--------------------------------------------------------
prompt <a name="Parameter Not Default"></a>
prompt <font size="+1" face="Arial,Helvetica,Geneva,sans-serif" color="#336699"><b>Parameter Not Default</b></font><hr align="left" width="460">
prompt <u1><li><b>Show Parameter which is not default </b></li></u1>
CLEAR COLUMNS BREAKS COMPUTES
--BREAK ON report ON owner
--COMPUTE sum LABEL '<font color="#990000"><b>Total: </b></font>' OF obj_count ON report
prompt <center>[<a class="noLink" href="#top">Back to Top</a>]</center><p>
--返回top:
prompt <center>[<a class="noLink" href="#top">Back to Top</a>]</center><p>
--html中去除owner重复:
BREAK ON report ON owner SKIP 2
BREAK ON report ON owner
--清除col,breaks,computs格式:
CLEAR COLUMNS BREAKS COMPUTES
--html中添加sum汇总结果:
COMPUTE sum LABEL '<font color="#990000"><b>Total: </b></font>' OF obj_count ON report
--下面是count汇总html:
COMPUTE count LABEL '<font color="#990000"><b>Total: </b></font>' OF obj_count ON report
--下面是我仿照awr生成的html结果示例:
参考文档:
https://docs.oracle.com/cd/B19306_01/server.102/b14357/ch7.htm#CHDCECJG
————————————————
版权声明:本文为CSDN博主「久违的太阳」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/su377486/article/details/104363392