使用SQLPLUS生成HTML报表
2009-12-29 15:44
471 查看
我们可以在SQLPLUS中手工运行AWR,ASH的脚本生成HTML报表,下面来简单讲讲怎么利用SQLPLUS来生成HTML报表
在SQLPLUS中有个命令(具体可以参考官方文档SQLPLUS部分)
SET MARK[UP] HTML [ON | OFF] [HEAD text] [BODY text] [TABLE text] [ENTMAP {ON | OFF}] [SPOOL {ON | OFF}] [PRE[FORMAT] {ON | OFF}]
一:首先在SQLPLUS中设置
set mark html on spool on entmap off pre off
这样设置过后,利用spool 导出为html,SQLPLUS将会自动的为我们创建HTML格式,
注意:如果设置pre 为on,那么输出的不是HTML格式,默认为off,
entmap 默认为on ,它会将>换成HTML中的>来显示,所以我将其设置为off
二:为了格式化输出,我们需要对输出内容格式化
set echo off 这样设置之后不会在HTML报表中显示执行过的SQL语句
set feedback off 这样设置过后不会在HTML报表中显示已经处理多少行
set heading on 设置标题显示
set termout off 关闭在屏幕上的输出,这样可以加快spool执行速度
set linesize 200 设置行宽度为120
set pagesize 1000 设置一页显示1000行
set trimout off 去掉 每行后面多余的空格
三:利用spool 输出为 *.html
spool c:/test.html
四:写下要执行的SQL语句
五:spool off
例如要查询表空间利用率,并将结果输出为HTML报表格式:
将下面的语句保存为一个SQL脚本,然后在SQLPLUS中调用
SET MARKUP HTML ON SPOOL ON pre off entmap off
SET ECHO OFF
SET TERMOUT OFF
SET TRIMOUT OFF
set feedback off
set heading on
set linesize 200
set pagesize 10000
col tablespace_name format a15
col total_space format a10
col free_space format a10
col used_space format a10
col used_rate format 99.99
spool c:/test.html
select a.tablespace_name,a.total_space_Mb||'m' total_space,b.free_space_Mb||'m'
free_space,a.total_space_Mb-b.free_space_Mb||'m' used_space,
(1-(b.free_space_Mb/a.total_space_Mb))*100 used_rate,a.total_blocks,b.free_blocks from
(select tablespace_name,sum(bytes)/1024/1024 total_space_Mb,sum(blocks) total_blocks from dba_data_files
group by tablespace_name) a,
(select tablespace_name, sum((bytes)/1024/1024) free_space_Mb,sum(blocks) free_blocks from dba_free_space
group by tablespace_name) b
where a.tablespace_name=b.tablespace_name order by used_rate desc;
spool off
SQL> @test;
报表的截图
在SQLPLUS中有个命令(具体可以参考官方文档SQLPLUS部分)
SET MARK[UP] HTML [ON | OFF] [HEAD text] [BODY text] [TABLE text] [ENTMAP {ON | OFF}] [SPOOL {ON | OFF}] [PRE[FORMAT] {ON | OFF}]
一:首先在SQLPLUS中设置
set mark html on spool on entmap off pre off
这样设置过后,利用spool 导出为html,SQLPLUS将会自动的为我们创建HTML格式,
注意:如果设置pre 为on,那么输出的不是HTML格式,默认为off,
entmap 默认为on ,它会将>换成HTML中的>来显示,所以我将其设置为off
二:为了格式化输出,我们需要对输出内容格式化
set echo off 这样设置之后不会在HTML报表中显示执行过的SQL语句
set feedback off 这样设置过后不会在HTML报表中显示已经处理多少行
set heading on 设置标题显示
set termout off 关闭在屏幕上的输出,这样可以加快spool执行速度
set linesize 200 设置行宽度为120
set pagesize 1000 设置一页显示1000行
set trimout off 去掉 每行后面多余的空格
三:利用spool 输出为 *.html
spool c:/test.html
四:写下要执行的SQL语句
五:spool off
例如要查询表空间利用率,并将结果输出为HTML报表格式:
将下面的语句保存为一个SQL脚本,然后在SQLPLUS中调用
SET MARKUP HTML ON SPOOL ON pre off entmap off
SET ECHO OFF
SET TERMOUT OFF
SET TRIMOUT OFF
set feedback off
set heading on
set linesize 200
set pagesize 10000
col tablespace_name format a15
col total_space format a10
col free_space format a10
col used_space format a10
col used_rate format 99.99
spool c:/test.html
select a.tablespace_name,a.total_space_Mb||'m' total_space,b.free_space_Mb||'m'
free_space,a.total_space_Mb-b.free_space_Mb||'m' used_space,
(1-(b.free_space_Mb/a.total_space_Mb))*100 used_rate,a.total_blocks,b.free_blocks from
(select tablespace_name,sum(bytes)/1024/1024 total_space_Mb,sum(blocks) total_blocks from dba_data_files
group by tablespace_name) a,
(select tablespace_name, sum((bytes)/1024/1024) free_space_Mb,sum(blocks) free_blocks from dba_free_space
group by tablespace_name) b
where a.tablespace_name=b.tablespace_name order by used_rate desc;
spool off
SQL> @test;
报表的截图
相关文章推荐
- 使用SQLPLUS生成HTML报表
- 使用SQLPLUS生成HTML报表
- 使用SQLPLUS生成HTML报表
- jasperreport生成html,Excel,PDF报表,数据源使用List
- 使用Apache Velocity生成HTML报表
- .net使用DotNetCharting控件生成报表统计图总结 (http://www.cnblogs.com/dreamof/archive/2008/07/18/1245887.html)
- 使用eclipse生成html格式注释文档 [ javadoc ]
- 使用sublime text3快速生成HTML头部信息
- php中使用python生成excel报表
- .net使用DotNetCharting控件生成报表统计图总结
- 使用FreeMarker生成静态HTML
- 使用C#和Excel进行报表开发(三)-生成统计图(Chart)
- 在.NET中不安装Office使用EPPlus生成带图表(Chart)的Excel报表
- 技巧和诀窍:使用ASP.NET 2.0 CSS 控件适配器生成CSS友好的HTML输出
- 如何使用iReport 和jasper生成报表(SQL传参数及中文文件名)
- 用模版生成HTML的的框架jquery.tmpl使用详解
- jmeter+ant+jenkins+mac 报告优化(三) 使用命令行执行jmeter方式生成多维度的图形化HTML报告
- 使用C#和Excel进行报表开发-生成统计图Chart
- 使用C#和Excel进行报表开发(三)-生成统计图(Chart)
- 使用freemarker生成html