ITPub博客

首页 > Linux操作系统 > Linux操作系统 > [20120817]sqlplus 输出html格式.txt

[20120817]sqlplus 输出html格式.txt

原创 Linux操作系统 作者:lfree 时间:2012-08-17 09:35:16 0 删除 编辑
[20120817]sqlplus 输出html格式.txt

许多blog介绍在sqlplus输出excel文件的方法,实际上执行的是:
set markup HTML ON
生成的是html格式的文件,只不过MS OFFICE可以当作电子表格文件打开!

利用这个特性,可以使用firefox打开.

参考链接如下:

建立html.sql文件:

http://uhesse.com/2011/06/30/sqlplus-output-in-nice-html-format/

----------------------------------------
-- get the last SQL*Plus output in HTML
-- after Tanel Poder
----------------------------------------

set termout off

set markup HTML ON HEAD " -
 -
" -
BODY "" -
TABLE "border='1' align='center' summary='Script. output'" -
SPOOL ON ENTMAP ON PREFORMAT OFF

spool myoutput.html

l
/

spool off
set markup html off spool off
host "E:\Program Files\Mozilla Firefox\firefox.exe" myoutput.html
set termout on

--注意修改firefox.exe的执行路径!调用html.sql之前,先执行要输出的sql语句.
--脚本巧妙的利用sqlplus的list(l)命令,调出上次执行的sql语句.

SQL> help l

 LIST
 ----

 Lists one or more lines of the most recently executed SQL command
 or PL/SQL block which is stored in the SQL buffer. Enter LIST with
 no clauses to list all lines. In SQL*Plus command-line you can also
 use ";" to list all the lines in the SQL buffer. The buffer has no
 command history list and does not record SQL*Plus commands.

 L[IST] [n | n m | n  * | n LAST | * | * n | * LAST | LAST]



 

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-741205/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    4006
  • 访问量
    7969454