Thursday, April 7, 2016

Generating Oracle Query output to a csv file

--Set the linesize large enough to accommodate the longest possible line.
SET LINESIZE 9999
--Turn off all page headings.
SET PAGESIZE 20000
--Turn off feedback
SET FEEDBACK OFF
/*
-- It will not return how many number of rows were returned after executing the query.
*/
--Eliminate trailing blanks at the end of a line.
SET TRIMSPOOL ON

SET TERMOUT OFF
/*
-- The output upon running the command/script will not not returned on the standard output screen.
*/

/*
-- set your column seperator to a comma for CSV file

*/

SET COLSEP ','

SPOOL excel_readable_file.csv

Query

spool off;

No comments:

Post a Comment