通过spool命令将oracle中的表转换成excel的格式 您所在的位置:网站首页 xls导入oracle 通过spool命令将oracle中的表转换成excel的格式

通过spool命令将oracle中的表转换成excel的格式

2023-07-26 23:38| 来源: 网络整理| 查看: 265

[注]:本帖为转帖的改进版本

----------------------------------------

关于将Oracle数据库中的表转换成excel格式,通过在microsoft的excel来查看,从网上找到实现的一种方式,如下:

步骤:

1.创建两个sql脚本,一个用于说明生成的查询结果的格式,并且调用另外的一个脚本,另外的一个脚本中的内容是查找需要的行的信息

2.进入sql*plus执行第一个脚本,从而生成.xls格式的表文件

 

过程如下:

1.创建man.sql,用于说明返回查询的格式及调用第二个脚本

--------

[oracle@10gr2 ~]$ cat man.sql

set linesize 200

set term off verify off feedback off pagesize999

set markup html on entmap ON spool onpreformat off

spool tables.xls #利用spool命令说明生成的xls表的名称

@get_tables.sql #第二个脚本的名字

spool off

exit

2.第二个脚本,指明要查询返回的行的信息

--------

[oracle@10gr2 ~]$ cat get_tables.sql

select * from user_tables; #示例

3.进入sqlplus执行该脚本

---------

[oracle@10gr2 ~]$ sqlplus scott/tiger #查询的表一定要在正确的用户下

 

SQL*Plus: Release 10.2.0.4.0 - Production onSat Nov 15 12:30:14 2014

 

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

 

 

Connected to:

Oracle Database 10g Enterprise EditionRelease 10.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining andReal Application Testing options

 

SQL> @man.sql

Disconnected from Oracle Database 10gEnterprise Edition Release 10.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining andReal Application Testing options

[oracle@10gr2 ~]$

4.查看生成的文件,通过ftp将.xls文件传送到本地,利用excel来查看

 

 

 

 

 

 

 

 



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有