分类: Oracle
2008-03-04 16:53:14
比如我下面的这个例子中,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