Just a short post. How to quickly output to CSV when using SQL*Plus with Oracle. Save the following to a file export_to_csv.sql:

set linesize 32767;
set heading on;
set headsep ,;
set colsep ,;
set pagesize 50000;
set trimspool on;
set termout off;
set feed off;
set underline off;
set echo off;

spool /path/to/export.csv;
-- your sql here
select * from table_name;
spool off;

Afterwards, log in to SQL*Plus and run using the command:

SQL> @export_to_csv.sql

Leave A Comment

Related Post

Read More
Read More
Read More
Read More