ORACLE: need to export table data without spaces between columns ORACLE: need to export table data without spaces between columns unix unix

ORACLE: need to export table data without spaces between columns


If you already have a CSV dump, then you can run the following command:

awk 'BEGIN{FS=",";OFS=""}{$1=$1}1' csv.dump > new.dump 

Untested:

SET HEADING OFFSET FEEDBACK OFFSPOOL $DESCSELECT col1 ||''|| col2 ||''|| col3 FROM table_name;SPOOL OFF;


From a "simplified oracle view" to "plain" characters with :

sed -n '3,$ s/\s//gp' file
$cat file      col1   col2   col3   col4      -------------------      sajal  singh  28     IND      hello  how    are    you$sed -n '3,$ s/\s//gp' filesajalsingh28INDhellohowareyou

Explanation: replace all white space (not line breaks) from line 3 to EOF with "nothing".


If you want the columns padded out but no additional spaces between the columns you can do:

set colsep ""

The default is to have a single space between the double-quotes, which puts a single space between the columns. You might also want to do:

set tab off

... to ensure that multiple spaces in the padding isn't converted to tabs, which looks fine for display but would be a pain parsing the file.

If you want no spaces at all, to do this within SQL*Plus you'd need to concatenate the columns:

 select col1 || col2 || col3 || col4 from table_name;

This is useful if you're putting a delimiter between the columns (e.g. making it a CSV), but I don't know what you'd be able to do with the data in the file if you squashed everything together without delimiters.