3

when i export query results into csv using netezza nzsql commndline , the o/p is printed to file in fixed length format. i.e if a col is defined as 4k length its printing out 4k length sting irrespective of lenght of the stored string in that field. As a result , the o/p file is getting huge due to lot of extra spaces. is there a way to get around it? I tried trimming columns , replace(field,' ','') but it didnt help.

command i am using :

nzsql -d {dbname} -u {username} -h {host} -c "select * from table_with_90_columns " -t -o output.csv

data
  • 61
  • 1
  • 6
  • You need to specify a delimiter, and I think you will find this covered in this question [here](http://stackoverflow.com/questions/30251399/how-to-output-a-file-using-tab-delimiter-in-netezza-nzsql) – ScottMcG Jun 04 '15 at 19:15
  • nzsql has a default delimiter of | . I see the fixed length o/p even if i go for a different delimiter. – data Jun 04 '15 at 22:08
  • I am curious whether it is possible to grab header sql types in addition to header names when using nzsql ... – Leonid Oct 08 '15 at 16:43

1 Answers1

0

When using nzsql to output delimited data, specify a delimiter of your choice with the -F option, and specify unformatted output with the -A option.

Or, use external tables as they will be quite a bit faster for data of any significant size.

ScottMcG
  • 3,867
  • 2
  • 12
  • 21