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

本文提供了一种方法,通过创建两个SQL脚本来将Oracle数据库中的表转换为Excel格式,以便在Excel中查看数据。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

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

关于将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来查看

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值