SQLPlus settings to generate tab-separated data file

user19387 picture user19387 · Sep 20, 2008 · Viewed 41.6k times · Source

Anyone have a good set of sqlplus configuration directives to help transform a given sql query into nicely tab separated output for pulling into a spreadsheet or further processing?

Answer

user158017 picture user158017 · Aug 15, 2011

As Justin pointed out in his link, using the set colsep function SQLPlus command saves typing a separator for each column.

But for tab-delimited, set colsep Chr(9) won't work.

For UNIX or LINUX, use set colsep ' ' with the space between the single-quotes being a typed tab.

For Windows, use these settings:

col TAB# new_value TAB NOPRINT
select chr(9) TAB# from dual;
set colsep "&TAB"

select * from table;