Remove Column Header into the Output Text file

前端 未结 2 629
别那么骄傲
别那么骄傲 2020-12-17 08:32

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

I have successfully created the text file using SPOOL, thru a script text file, but i

相关标签:
2条回答
  • 2020-12-17 09:10

    Add:

    set underline off
    

    to the beginning of the SQL script.

    In my SQL scripts I have:

    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 book for reference.

    0 讨论(0)
  • 2020-12-17 09:16

    SQLPLUS COMMAND Skipped: set heading off

    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.

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

    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:

    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 
    
    0 讨论(0)
提交回复
热议问题