IBM Support

How to export data from a DB2 database table (into a CSV file)

How To


Summary

Customer would like to export a Controller DB2 database table to a CSV (flat file).
- How can they do this?

Objective

Export all the data from a single (specific) DB2 database table, into a flat file (CSV).

Environment

This Technote is based on:

  • Controller 10.3.1
  • DB2 10.5
  • Data Studio 4.1.3

Steps

There are many different ways to export data from a DB2 database. This Technote suggests using a DB2 command similar to:

db2 CALL SYSPROC.ADMIN_CMD( 'EXPORT TO "C:\UTILS\export.csv" OF DEL MESSAGES ON SERVER SELECT * FROM <table_owner>.<tablename>' )

    

Steps:

1. Logon to the DB2 database server

2. Launch:  DB2 Command Window - Administrator

3. Run a command similar to:

db2 connect to <database_name>

  

4. Run a command similar to:

db2 CALL SYSPROC.ADMIN_CMD( 'EXPORT TO "C:\UTILS\export.csv" OF DEL MESSAGES ON SERVER SELECT * FROM <table_owner>.<tablename>' )

  

Example:

db2 CALL SYSPROC.ADMIN_CMD( 'EXPORT TO "C:\UTILS\export.csv" OF DEL MESSAGES ON SERVER SELECT * FROM FASTNET.WLOOKUPTABLEENTRIES' )

[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SS9S6B","label":"IBM Cognos Controller"},"Component":"","Platform":[{"code":"PF033","label":"Windows"}],"Version":"10.3.1","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
30 January 2019

UID

ibm10741797