SQL 附加到假脱机文件 Oracle
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39051834/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Append to spool file Oracle
提问by Sarath Avanavu
I have one script file called Test.sqlin D:\Scriptsfolder and the content of the file is given below
我在D:\Scripts文件夹中有一个名为Test.sql 的脚本文件,文件内容如下
SET SERVEROUTPUT ON
SET DEFINE OFF
SPOOL Test.log;
SELECT USER_NAME FROM TUP_USER WHERE USER_ID=1432;
SPOOL OFF;
SET DEFINE ON
SET SERVEROUTPUT OFF
I normally execute this by opening command prompt, locate to D:\Scriptsand give sqlplus username/password@Database
and then give @test.sql
to execute this and it will generate a log file called Test.log
我通常通过打开命令提示符来执行它,定位到D:\Scripts并给出sqlplus username/password@Database
然后给出@test.sql
执行它,它将生成一个名为Test.log的日志文件
Every time I execute this, it replaces the old file with the new data. I need to append new data to the file using spool. Is there a way to do that?
每次执行此操作时,它都会用新数据替换旧文件。我需要使用假脱机将新数据附加到文件中。有没有办法做到这一点?
Any help would be appreciated. Thanks in advance.
任何帮助,将不胜感激。提前致谢。
回答by Sarath Avanavu
Finally got the solution for this!
终于得到了这个解决方案!
Add append
after Test.log
添加append
后Test.log
SET SERVEROUTPUT ON
SET DEFINE OFF
SPOOL Test.log append;
SELECT USER_NAME FROM TUP_USER WHERE USER_ID=1432;
SPOOL OFF;
SET DEFINE ON
SET SERVEROUTPUT OFF
回答by shouzeb hasan
Just add append when you're writing the spool query:
只需在编写 spool 查询时添加 append:
spool d:\lab1.txt append;