0

I have the below query that saves the results to a csv file. How can I modify the query so the columns are separated by pipe '|' rather than comma? Also, when I open the csv file, the actual sql query is in the csv file as well, how I can exclude the query from the file?

Currently using SQL Developer.

Many Thanks.

spool c:\temp\myoutputfile.csv

select * from mytable;

spool off;

netraider
  • 267
  • 2
  • 8
  • 16
  • Possibly a partial duplicate of [this](http://stackoverflow.com/q/15907015/266304) or [this](http://stackoverflow.com/q/19033943/266304); also see [this blog post](http://www.thatjeffsmith.com/archive/2013/04/sql-developer-preferences-for-delimited-text-exports/), or [this one](http://www.thatjeffsmith.com/archive/2015/12/more-set-sqlformat-fun-in-sqlcl/) if you can use SQLcl instead of SQL Developer.. – Alex Poole Feb 24 '16 at 11:42

2 Answers2

0

before you start spooling the data you need to set column separator as pipe

set colsep "|"
Sandeep
  • 774
  • 3
  • 8
0

Spool is really a sql*plus command, so it acts differently in SQL Developer.

Take advantage of the power of SQL Developer. Just enter & execute your query in the worksheet. Then, in the resulting data grid, right-click to see a context menu and select export. This gives you access to many variations for the export, including changing the delimiter. (See Preferences>Database>Utilities>Export for more variations.)

Beege
  • 665
  • 4
  • 18