IBM Support

Sending query results to an output file

Question & Answer


Question

How do I spool results to an output file using nzsql? 

Answer

It is common practice to use nzsql to spool query results into a regular file using either of these commands:

nzsql -d <database> -u <user> -pw <passwd> -A -t -c "<query>" -o <file>
nzsql -d <database> -u <user> -pw <passwd> -A -t -f query.sql -o <file>

This will work most of the time but there is a limitation: If the selected output file grows over 2GB, nzsql will fail with error message

Error: file too large.

To avoid this limitation, spool the results of your query to an external table, using this syntax:

CREATE EXTERNAL TABLE [table_name] 'filename'
[USING external_table_options]
AS select_clause

[{"Product":{"code":"SSULQD","label":"IBM PureData System"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":null,"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"1.0.0","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Historical Number

NZ433383

Document Information

Modified date:
17 October 2019

UID

swg21567479