Pedro's blog: db2, mysql, php, linux and performance


DB2 export UTF8
25/02/2010, 18:54
Filed under: DB2,GNU/Linux,macosx | Tags: , , , , ,

Some tips and tricks.

Exporting data from DB2 to files in linux (I like EXPORT but you also can use UNLOAD or a simple SELECT and the redirection >):

$ db2 EXPORT TO “/tmp/unload.txt” OF del MODIFIED BY COLDEL, CHARDEL* SELECT * FROM MYTABLE

This command will export the table MYTABLE to the file /tmp/unload.txt formatting the fields like *COL1*,*COL    2*,*COL NUM 3*,…,*COL N*

In MacOSX formatting the files from UTF-8 format to ISO-8859-1 format (because the special spanish chars áéíóúñ…):

$ iconv -f UTF-8 -t ISO-8859-1 unload.txt > unload_8859.txt