ITPub博客

首页 > 数据库 > Oracle > Oracle 10G中spool新增加的方法

Oracle 10G中spool新增加的方法

原创 Oracle 作者:charsi 时间:2010-11-23 10:48:54 0 删除 编辑

使用Oracle的时候,我们经常使用spool这个工具,来看看10G和9i中,SPOOL的用法:

10G中
SQL> help spool

SPOOL
-----

Stores query results in a file, or optionally sends the file to a printer.
In iSQL*Plus, use the Preferences screen to direct output to a file.

SPO[OL] [file_name[.ext] [CRE[ATE] | REP[LACE] | APP[END]] | OFF | OUT]

Not available in iSQL*Plus


SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production


9i中:
SQL> help spool

SPOOL
-----

Stores query results in an operating system file, or sends the
file to a printer.
In iSQL*Plus, output can be directed to a file.

SPO[OL] [file_name[.ext] | OFF | OUT]

Not available in iSQL*Plus


SQL> spool out
not spooling currently
SQL>
SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
PL/SQL Release 9.2.0.8.0 - Production
CORE 9.2.0.8.0 Production
TNS for HPUX: Version 9.2.0.8.0 - Production
NLSRTL Version 9.2.0.8.0 - Production


可以看出,在9i中spool的用法比较简单,就是on和off的两种功能;而到了10G中之后,可以在spool的文件名之后使用create(创建)、replace(替换)、append(添加)三个参数,尤其是append这个参数的引入.不用再像在9i中的时候,如果再次spool的时候,就会把原来的文件替换掉.


SQL> spool test_spool cre
SQL> !ls -l
total 0
-rw-r--r-- 1 oracle dba 0 Feb 9 14:38 test_spool.lst

SQL> spool off


SQL> spool test_spool append
SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production


SQL> spool off

[@more@]

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/23850820/viewspace-1045875/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2010-05-04

  • 博文量
    96
  • 访问量
    406716