⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 35220.htm

📁 一本很基础的SQL讲解
💻 HTM
字号:
<link href="./dzs_cs.css" rel="stylesheet" type="text/css" /><table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">      <tr>        <td>&nbsp;</td>      </tr>      <tr>        <td height="24" align="center" valign="bottom" class="d_font3">用SQL PLUS构建excel或html输出</td>      </tr>      <tr>        <td height="3" bgcolor="#E3E3E3"></td>      </tr>      <tr>        <td>&nbsp;</td>      </tr>      <tr>        <td class="d_font4"><P>通过SQL*PLUS我们可以构建友好的输出,满足多样化用户需求。本例通过简单示例,介绍通过sql*plus输出xls,html两种格式文件。 
<P>首先创建两个脚本:
<P>1.main.sql 
<P>用以设置环境,调用具体功能脚本。 
<P>2.功能脚本-get_tables.sql 
<P>为实现具体功能之脚本。 
<P>通过这样两个脚本可以避免spool中的冗余信息。 
<P>示例如下:
<P>1.main.sql脚本: 
<TABLE cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=400 align=center borderColorLight=black border=1>
<TBODY>
<TR>
<TD class=code bgColor=#e6e6e6><PRE>[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</PRE></TD></TR></TBODY></TABLE>
<P>2.get_tables.sql脚本: 
<TABLE cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=400 align=center borderColorLight=black border=1>
<TBODY>
<TR>
<TD class=code bgColor=#e6e6e6><PRE>[oracle@jumper utl_file]$ more get_tables.sql 
select owner,table_name,tablespace_name,blocks,last_analyzed
from all_tables order by 1,2;</PRE></TD></TR></TBODY></TABLE>
<P>3.执行并获得输出: 
<TABLE cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=400 align=center borderColorLight=black border=1>
<TBODY>
<TR>
<TD class=code bgColor=#e6e6e6><PRE>[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]$ </PRE></TD></TR></TBODY></TABLE>
<CENTER></CENTER>
<P>此处输出为xls文件,通过下图我们可以看到输出效果: 
<CENTER><IMG src="/files/uploadimg/20061124/1205370.jpg"></CENTER>
<P>把main.sql脚本中的,spool tables.xls更改为spool tables.htm,我们可以获得htm格式输出,效果如下图: 
<CENTER><IMG src="/files/uploadimg/20061124/1205371.jpg"></CENTER>
<P>(责任编辑:铭铭 <A href="mailto: mingming_ky@126.com">mingming_ky@126.com</A> TEL:(010)68476636)</P></td>      </tr>      <tr>        <td class="d_font4">&nbsp;</td>      </tr>    </table>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -