How do I spool to a CSV formatted file using SQLPLUS?

后端 未结 16 1163
执笔经年
执笔经年 2020-11-22 15:40

I want to extract some queries to a CSV output format. Unfortunately, I can\'t use any fancy SQL client or any language to do it. I must use SQLPLUS.

How do I do it?

16条回答
  •  爱一瞬间的悲伤
    2020-11-22 16:26

    I use this command for scripts which extracts data for dimensional tables (DW). So, I use the following syntax:

    set colsep '|'
    set echo off
    set feedback off
    set linesize 1000
    set pagesize 0
    set sqlprompt ''
    set trimspool on
    set headsep off
    
    spool output.dat
    
    select '|', .*, '|'
      from 
    where spool off

    And works. I don't use sed for format the output file.

    提交回复
    热议问题