Post date: Aug 29, 2014 8:23:15 AM
I want to get the flat comma-separated file from terminal that runs SQLPlus. Here is how I manage to do it.
further resources:
sqlplus <user_id>_ro@<db_name>SQL> set colsep , -- separate columns with a commaSQL> set trimspool on -- remove trailing blanksSQL> set pagesize 0 -- No header rowsSQL> set echo offSQL> set feedback offSQL> set headsep off -- this may or may not be useful...depends on your headings.SQL> set linesize X -- X should be the sum of the column widthsSQL> set numw X -- X should be the length you want for numbers (avoid scientific notation on IDs)SQL> spool '/tmp/kittipat_out_data.dat';SQL> spool off;sed 's/ \+//g' /tmp/kittipat_out_data.dat > /tmp/kittipat_out_data_clean.dat