清除 Oracle spool 中的标题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2100293/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 02:21:04  来源:igfitidea点击:

Clear the heading in Oracle spool

oraclespool

提问by Srinivasan Thirunavukkarasu

I have spooled a file before running the below command and got the output like this,

在运行以下命令之前,我已经假脱机一个文件并得到这样的输出,

I have set heading off, feedback off

我已经出发,反馈关闭

SET HEADING OFF SET FEEDBACK OFF SPOOL D:\TEST.TXT SELECT SYSDATE FROM DUAL; SPOOL OFF

SET HEADING OFF SET FEEDBACK OFF SPOOL D:\TEST.TXT SELECT SYSDATE FROM DUAL; 脱机

OUTPUT in TEST.TXT:

TEST.TXT 中的输出:

SQL> SELECT SYSDATE FROM DUAL;

SQL> SELECT SYSDATE FROM DUAL;

20-JAN-09

09 年 1 月 20 日

SQL> SPOOL OFF

SQL> 假脱机关闭

How can i remove the two SQL> lines. I want only the output.

如何删除两条 SQL> 行。我只想要输出。

Thanks in advance.

提前致谢。

回答by Tony Andrews

The command you need is:

你需要的命令是:

SET ECHO OFF

However, it only works for code run from scripts, not command entered interactively. You would create a script file like this (e.g. called test.sql):

但是,它仅适用于从脚本运行的代码,而不适用于交互式输入的命令。您将创建一个这样的脚本文件(例如称为test.sql):

SET HEADING OFF FEEDBACK OFF ECHO OFF PAGESIZE 0
SPOOL D:\TEST.TXT 
SELECT SYSDATE FROM DUAL; 
SPOOL OFF

Then in SQL Plus run it like this:

然后在 SQL Plus 中像这样运行它:

SQL> @test

I added PAGESIZE 0 to the SET command to remove the blank line you otherwise get before the date in the output file.

我在 SET 命令中添加了 PAGESIZE 0 以删除您在输出文件中的日期之前获得的空行。

回答by Vijay

use this:

用这个:

#!/bin/ksh
CONNECT_STRING=dbapp/dbapp@inst
SQLPLUS_SETTINGS="SET PAGESIZE 1000 LINESIZE 500 ECHO OFF TRIMS ON TAB OFF FEEDBACK OFF HEADING OFF"
SQL_RESULT=`sqlplus -s ${CONNECT_STRING} << EOF
${SQLPLUS_SETTINGS}
select sysdate from dual;
exit;
EOF`

echo $SQL_RESULT >output_file