使用SQL*PLUS构建完美excel或html输出
轉(zhuǎn)自:http://hong9270503.blog.163.com/blog/static/127292320091611319516/
?
通過(guò)SQL*PLUS我們可以構(gòu)建友好的輸出,滿(mǎn)足多樣化用戶(hù)需求。
本例通過(guò)簡(jiǎn)單示例,介紹通過(guò)sql*plus輸出xls,html兩種格式文件.
首先創(chuàng)建兩個(gè)腳本:
1.main.sql
用以設(shè)置環(huán)境,調(diào)用具體功能腳本
2.功能腳本-get_tables.sql
為實(shí)現(xiàn)具體功能之腳本
通過(guò)這樣兩個(gè)腳本可以避免spool中的冗余信息.
示例如下:
1.main.sql腳本:
[oracle@jumper utl_file]$ more main.sql
set linesize 200
set term off verify off feedback off pagesize 999
set markup html on entmap ON spool on preformat off
spool tables.xls
@get_tables.sql
spool off
exit
2.get_tables.sql腳本:
[oracle@jumper utl_file]$ more get_tables.sql
select owner,table_name,tablespace_name,blocks,last_analyzed
from all_tables order by 1,2;
3.執(zhí)行并獲得輸出:
[oracle@jumper utl_file]$ sqlplus "/ as sysdba" @main
SQL*Plus: Release 9.2.0.4.0 - Production on Mon Apr 25 10:30:11 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production
[oracle@jumper utl_file]$ ls -l tables.xls
-rw-r--r-- 1 oracle dba 69539 Apr 25 10:30 tables.xls
[oracle@jumper utl_file]$
此處輸出為xls文件,通過(guò)下圖我 們可以看到輸出效果:
把main.sql腳本中的,spool tables.xls更改為spool tables.htm,我們可以獲得htm格式輸出,效果如下圖:
總結(jié)
以上是生活随笔為你收集整理的使用SQL*PLUS构建完美excel或html输出的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Oracle架构入门级基础
- 下一篇: 九号n85c,我有一个锂电池60v40a