CSV output (FORMAT CSV)
To produce an output file in which the unloaded data is in comma-separated-value (CSV) format, specify FORMAT CSV.
Optionally, you can specify additional keywords. CSV options are TERMINATEDBY, ENCLOSEDBY, AND, NULLSTRING, and RTRIM. When you use more than one option, the syntax must follow the sequence in the CSV syntax diagram. For example, if you use TERMINATEDBY, that option must appear before ENCLOSEDBY or NULLSTRING.
For an example of this feature, see Example 12 — Unloading to CSV format.
When you specify FORMAT CSV, UNLOAD PLUS performs the following functions:
- Uses the character specified by the TERMINATEDBY option to separate each field from other fields
- Uses the character specified by the ENCLOSEDBY option and the character specified by the AND option to enclose each nonnumeric field with a pair of characters
- Produces all data in external format (even if you specify an explicit data type)
- Creates all fields as variable length except for those fields for which you specify an explicit data type and length
Restrictions on FORMAT CSV
- If you specify FORMAT CSV when you are unloading LOB or XML data, UNLOAD PLUS terminates.
- If you specify USELRECL YES with FORMAT CSV, UNLOAD PLUS ignores USELRECL YES.
- If you specify TIMEFMT, DATEFMT, or TSFMT with FORMAT CSV and CNTLCARDS BMCLOAD, UNLOAD PLUS terminates.
- UNLOAD PLUS does not support conversions to VARCHAR, VARGRAPHIC, BINARY, VARBINARY, and ROWID data types when you specify FORMAT CSV.
TERMINATEDBY, ENCLOSEDBY, and AND options
When you specify FORMAT CSV, UNLOAD PLUS assumes that the values for the TERMINATEDBY, ENCLOSEDBY, and AND options are in EBCDIC format and translates them, if necessary, to the CCSID of the output. To ensure that applications can read your CSV output, note the following guidelines:
- Ensure that the values that you specify (or default to) for these options are not contained in your column data, or that your column data will not translate to these values. Otherwise, applications might read the resulting output incorrectly.
- For these options, avoid specifying values that would expand to multiple-byte characters when the values are translated.
- Avoid specifying any of the following characters:
- X'0A' (line feed in ASCII and Unicode)
- X'0D' (carriage return in ASCII, Unicode, and EBCDIC)
- X'15' (new line in EBCDIC)
- X'25' (line feed in EBCDIC)
LOADPLUS interaction with FORMAT CSV
Although supported, using the FORMAT CSV option of UNLOAD PLUS and LOADPLUS together is not the most efficient method for using these two products to migrate Db2 data.
Instead of FORMAT CSV, use the following guidelines for migrating Db2 data with UNLOAD PLUS and LOADPLUS:
- If your table structures are almost identical, we recommend that you specify FORMAT BMCLOAD (in UNLOAD PLUS) and FORMAT BMCUNLOAD (in LOADPLUS) to migrate Db2 data.
- If your table structures are not similar enough to use this method, we recommend that you use the FORMAT INTERNAL option.
If you must reload CSV data by using LOADPLUS, we recommend that you specify CNTLCARDS BMCLOAD in your UNLOAD PLUS job. Specifying this option tells UNLOAD PLUS to generate control cards for LOADPLUS.
Related topics