Video: Export data from DB2 table to CSV file in a few clicks
This video shows how to export data from DB2 table to CSV file in a few clicks with Withdata DBToFile, or with the free Export DB2 to CSV online tool. It covers the db2 table side and the CSV side.
Export DB2 to CSV: what this does
This shows how to export a DB2 table — or a query result — to a CSV file, so the data can be opened in Excel, loaded into another database, or handed to a script. The video above is the full flow; the notes below cover the DB2-specific details.
Steps
Connect to DB2 (host, port, database, user). The tool works with DB2 for LUW; for DB2 for IBM i (AS/400) connect to the system and library.
Choose the schema/table, or switch to Query to export a filtered SELECT.
Select CSV as the destination format.
Set the delimiter, quoting and encoding, then click Export.
Save the session to repeat the export from the command line or a scheduled task.
DB2 to CSV: details worth knowing
CHAR is padded. DB2 CHAR(n) values keep their trailing spaces; VARCHAR does not. Trim on export if the padding is not wanted.
DECIMAL precision.DECIMAL/NUMERIC are written with their full scale, so the CSV keeps the exact value instead of a rounded float.
Date and time. DB2 DATE, TIME and TIMESTAMP are exported in ISO form (YYYY-MM-DD, HH:MM:SS, with fractional seconds for timestamps).
CLOB and BLOB.CLOB text is written as text; BLOB/XML columns have no CSV equivalent and are written as text or skipped.
Code page (CCSID). If the database uses EBCDIC or a non-UTF-8 CCSID, set the output encoding so accents and non-Latin characters survive.
Schema names. DB2 tables are qualified by schema (often DB2INST1); pick the right schema if two tables share a name.
FAQ
Can I export only some rows or columns?
Yes — use a query and export the result instead of the whole table.
Can it run on a schedule?
Yes; save the session and call it from the command line or Windows Task Scheduler.
Do I need the DB2 client installed?
The tool connects to DB2 directly, so no separate db2 client is required.