How to: Oracle Sqlplus important flags for spool a table into CSV

How to: Oracle Sqlplus important flags for spool a table into CSV

Hello,

If you are trying to export a large table from a database via SQL Developer, it will take a lot of time. So to reduce the time and effort and you can log into or connect to remote Oracle DB via SQLPlus.

And while importing the data, to get proper structuring to your data below flags will help you.

set colsep ,  
set headsep off
set pagesize 0
set trimout on
set feedback off
set trimspool on
set linesize 32767
set echo off
SET TERMOUT OFF

For explanation of those flags, please read : https://docs.oracle.com/cd/B19306_01/server.102/b14357/ch12040.htm

So if you are planning to export a table then whole .sql file should look like below

set colsep ,
set headsep off
set pagesize 0
set trimout on
set feedback off
set trimspool on
set linesize 32767
set echo off
SET TERMOUT OFF
spool 4802.csv
SELECT player||','||name||','||value FROM player WHERE value IN ('Industry', 'Title');
spool off

Hope it will help you.