Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Exporting table data into csv file using SQLPLUS.. urgent help !

HKumar679Aug 22 2016 — edited Aug 26 2016

I tried the below sql script to extract the table columns into excel file. I could see the file generated but its a emp file.. no data extracted.

Am I missing anything here? I am running this script from my local PC using sqlplus.exe

Please help !

query.sql:-

set termout off

set hea off

set pagesize 0

spool lecturer_output.csv

select '"'||Col1||'","'||Col2||'","'||Col3||'","'||Col4||'","'||Col5||'","'||Col6||'","'||Col7||'",'||Col8||',"'||Col9||'","'||Col10||'","'||Col11||'","'||Col12||'",'||Col13||','||Col14||','||Col15 from Tablename

spool off

Tablename:-

  Col1         VARCHAR2(10 CHAR),

  Col2    VARCHAR2(10 CHAR),

  Col3          VARCHAR2(80 CHAR),

  Col4      VARCHAR2(10 CHAR),

  Col5          VARCHAR2(10 CHAR),

  Col6        VARCHAR2(10 CHAR),

  Col7      VARCHAR2(20 CHAR),

  Col8          NUMBER,

  Col9      VARCHAR2(10 CHAR),

  Col10      VARCHAR2(20 CHAR),

  Col11        VARCHAR2(10 CHAR),

  Col12   VARCHAR2(10 CHAR),

  Col13     NUMBER,

  Col14  NUMBER,

  Col15 NUMBER

This post has been answered by William Robertson on Aug 23 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 23 2016
Added on Aug 22 2016
17 comments
3,323 views