exa-Vandana
Moderator
Moderator

BACKGROUND

To export CSV files from IBM DB2

Options to export csv from IBM DB2

 

Option 1:

Using the IBM command line processor:

  • Connect to the database you want to export.
    DB2_1.png
  • Use the EXPORT TO-command combined with a SELECT query to export a table
    (Documentation: https://www.ibm.com/support/knowledgecenter/SSEPGG_9.8.0/com.ibm.db2.luw.admin.cmd.doc/doc/r0008303....)
  • We recommend to apply following parameters to ensure compatible formatting for your exported csv file:
    o MODIFIED BY datesiso
    -> exports dates in ISO format (YYYY-MM-DD)
    o MODIFIED BY timestampformat=”YYYY-MM-DD HH:MM:SS”
    -> exports timestamps in selected format
    o COALESCE(column,’’)
    -> checks if content of data field equals NULL and replaces it with “” (empty string) if necessary.
    This addition is needed for every selected column that allows NULL values.

Example:

DB2_2.png

Additional Notes:

  • IBM command line processor automatically masks double quotes ("Example" -> ""Example"")

 

Option 2:

Using the IBM Data Studio:

  • Connect to the database you want to export
  • Select the table you want to export
    DB2_3.png
  • Open context menu by right clicking on the table
  • Select the option Unload -> With Export Utility to open the integrated export tool
    DB2_4.png
  • Select JDBC as Run method
  • Pick your path and file name for the csv file
    DB2_5.png
  • To specify additional options, select the tab called Options (top left)
  • To ensure a compatible format for your csv file, you should check the available control boxes as follows
    DB2_6.png
  • Click Run to start exporting the table
    DB2_7.png
  • You will find the csv file in your selected path

Additional Notes:

  • IBM Data Studio automatically converts NULL to "" (empty string)
  • IBM Data Studio automatically masks double quotes ("Example" -> ""Example"")
Version history
Revision #:
3 of 3
Last update:
‎20-08-2020 03:36 PM
Updated by:
 
Contributors