oracle 将列标题删除到输出文本文件中

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

Remove Column Header into the Output Text file

oracleoracle-sqldevelopersqlplusspoolcolumnheader

提问by Marvin Wong

I want to create a flat file (text file) of my query from Oracle SQL Developer.

我想从 Oracle SQL Developer 创建我的查询的平面文件(文本文件)。

I have successfully created the text file using SPOOL, thru a script text file, but i want to remove the header of each column into my output.

我已经使用 SPOOL 通过脚本文本文件成功创建了文本文件,但我想将每列的标题删除到我的输出中。

I am getting this output:

我得到这个输出:

Header000001 Header000002
------------ ------------
Adetail1     Bdetail1
Adetail2     Bdetail2
Adetail3     Bdetail3

But, I want to get this output:

但是,我想得到这个输出:

Adetail1Bdetail1
Adetail2Bdetail2
Adetail3Bdetail3

I already tried the command "set heading off", but a message says:

我已经尝试过“设置航向”命令,但一条消息说:

"SQLPLUS COMMAND Skipped: set heading off".

These are the inputs I've issued:

这些是我发布的输入:

spool on; 
spool C:\SQLFiles\PSB_ATMLKP.txt; 
set newpage 0; 
set echo off; 
set feedback off; 
set heading off; 

select terminal_number, terminal_name from terminal_table; 

spool off;

回答by Lalit Kumar B

SQLPLUS COMMAND Skipped: set heading off

SQLPLUS 命令跳过:设置航向

That message is most likely because you are not executing it through SQL*Plus, but some GUI based tool. You are using SQLPlus command in SQL Developer. Not all SQL*Plus commands are guaranteed to work with SQL Developer.

该消息很可能是因为您不是通过SQL*Plus,而是通过一些基于 GUI 的工具来执行它。您正在 SQL Developer 中使用 SQLPlus 命令。并非所有 SQL*Plus 命令都能保证与SQL Developer 一起使用

I would suggest you execute the script in SQLPlusand you would see no issues.

我建议你在SQLPlus 中执行脚本,你不会看到任何问题。

You need:

你需要:

SET HEADING OFF

This will not include the column headers in the output.

这将不包括输出中的列标题。

Alternatively, you could also do this:

或者,您也可以这样做:

SET PAGESIZE 0

Using SQL Developer Version 3.2.20.10:

使用 SQL Developer 版本 3.2.20.10

spool ON
spool D:\test.txt
SET heading OFF
SELECT ename FROM emp;
spool off

enter image description here

在此处输入图片说明

Spool file got created with no issues:

创建假脱机文件没有问题:

> set heading OFF
> SELECT ename FROM emp
SMITH      
ALLEN      
WARD       
JONES      
MARTIN     
BLAKE      
CLARK      
SCOTT      
KING       
TURNER     
ADAMS      
JAMES      
FORD       
MILLER     

 14 rows selected 

回答by Tomas Maracek

Add:

添加:

set underline off

to the beginning of the SQL script.

到 SQL 脚本的开头。

In my SQL scripts I have:

在我的 SQL 脚本中,我有:

SET TERMOUT OFF
set colsep |
set pagesize 0 
set trimspool on
set pagesize  0 embedded on
SET heading on
SET UNDERLINE OFF
spool file_path
-- your SQL here
spool off

See this bookfor reference.

请参阅本书以供参考。