Focus On Oracle

Installing, Backup & Recovery, Performance Tuning,
Troubleshooting, Upgrading, Patching, Zero-Downtime Upgrade, GoldenGate

Oracle Exadata ,Oracle ODA, Oracle ZDLRA


当前位置: 首页 » 技术文章 » Oracle

如何使用SQL*Plus定制HTML报表格式

用sqlplus生成html文件时,我们可以定制Head,body,table等格式,用法为

SQL> set markup
Usage: SET MARKUP HTML [ON|OFF] [HEAD text] [BODY text]
 [TABLE text] [ENTMAP {ON|OFF}] [SPOOL {ON|OFF}] [PRE[FORMAT] {ON|OFF}]
SQL>


下面的格式样例为AWR报告的样式表的缩写版,可以查看AWR报告源码获得

注意:最后面的符号(-)起到连接的作用

set markup html on spool on preformat off entmap off -
head ' -
  <title>ORACLE Database Recover Check Report</title> -
  <style type="text/css"> -
    body              {font:9pt Arial,Helvetica,sans-serif; color:black; background:White;} -
    p                 {font:9pt Arial,Helvetica,sans-serif; color:black; background:White;} -
    table,tr,td       {font:9pt Arial,Helvetica,sans-serif; color:Black; background:#FFFFCC; padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;} -
    th                {font:bold 9pt Arial,Helvetica,sans-serif; color:White; background:#0066CC; padding:0px 0px 0px 0px;} -
    h1                {font:bold 12pt 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;} -
    a                 {font:10pt Arial,Helvetica,sans-serif; color:#0066CC; margin-top:0pt; margin-bottom:0pt; vertical-align:top;text-decoration: none;} -
    a.link            {font:10pt Arial,Helvetica,sans-serif; color:#0066CC; margin-top:0pt; margin-bottom:0pt; vertical-align:top;text-decoration: none;} -
  </style>' -
body   'BGCOLOR="#C0C0C0"' -
table  'WIDTH="100%"' 

SQL> set markup html on
SQL&gt;

SQL> set markup html on entmap off

<br>
SQL> select * from dual;
<br>
<p>
<table WIDTH="100%">
<tr>
<th scope="col">
DUM
</th>
</tr>
<tr>
<td>
X
</td>
</tr>
</table>
<p>

SQL>


Reference

http://docs.oracle.com/cd/B10501_01/server.920/a90842/ch13.htm

http://docs.oracle.com/cd/B10501_01/server.920/a90842/ch4.htm#1005909

http://docs.oracle.com/database/121/SQPUG/ch_seven.htm#SQPUG528



关键词:sql 

相关文章

Oracle SqlDeveloper很强悍
如何查看SQL的执行顺序?
如何使用SQL*Plus定制HTML报表格式
Top