Chinaunix首页 | 论坛 | 博客
  • 博客访问: 70132
  • 博文数量: 24
  • 博客积分: 1410
  • 博客等级: 上尉
  • 技术积分: 245
  • 用 户 组: 普通用户
  • 注册时间: 2007-12-25 18:16
文章分类

全部博文(24)

文章存档

2008年(21)

2007年(3)

我的朋友
最近访客

分类: Oracle

2008-03-04 16:53:14

一般分为2个SQL文件
1)执行SQL的文件
2)调用1)中的sql完成spool的文件


比如我下面的这个例子中,data.sql是用来真正取数据的SQL文件,do.sql是用来完成spool

动作的SQL文件。
 

data.sql内容如下:

select * from zrp;

do.sql 是完成spool的SQL文件,在do.sql中调用了data.sql,内容如下:
set heading off feedback off term off pagesize 0
spool e:info.txt
@e:data.sql
spool off
exit


然后测试看看:

E:>sqlplus study/study @do.sql

SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 7月 26 12:46:42 2007

Copyright (c) 1982, 2005, Oracle. All rights reserved.

连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

从 Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options 断开

E:>more info.txt
1
2
3
4
5
6
7
8


E:>

另外也可以使用类似如下的bat文件完成(unix的shell scripts就更简单了,不再多说).

edit test.bat

sqlplus -s /nolog @e:data.sql

 

data.sql的内容如下:

conn study/study
set heading off feedback off term off pagesize 0
spool e:info.txt
select * from zrp;
spool off
exit

阅读(2194) | 评论(0) | 转发(0) |
0

上一篇:sed高级实例

下一篇:虚拟主机的配置

给主人留下些什么吧!~~