netezzanzsql

netezza nzsql export query results into csv file


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


Solution

  • 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.