MySQL Forums
Forum List  »  IBM DB2

Re: MYSQL to DB2 Migration
Posted by: Kamran Saadatjoo
Date: July 26, 2010 05:39PM

Is the data you’re generating going to be loaded to DB2 with the IMPORT command? If so, I think you might want to use the SELECT … OUTFILE command with character fields terminating with double-quotes, something like below:

SELECT *
FROM tbl
INTO OUTFILE ‘outfile.txt’
FIELDS ESCAPED BY ‘’
OPTIONALLY ENCLOSED BY ‘”’
TERMINATED BY ‘,’
LINES TERMINATED BY ‘\n’;

If your DB2 is on Windows, then do “LINES TERMINATED BY ‘\r\n’”.

The only problem with this is that MySQL substitutes the word NULL in places where a column data is null, whereas DB2 likes the data to empty (two column delimiters back-to-back). So, you’ll have to get rid of the words NULL in the resulting file. Then in DB2, you’ll use the IMPORT command with input file of type DEL and supply the file you just generated.

If the above solution does not work for you, you’ll have to have a more elaborate SELECT statement. I hope this helps.

Options: ReplyQuote


Subject
Views
Written By
Posted
6931
July 26, 2010 01:00PM
Re: MYSQL to DB2 Migration
3703
July 26, 2010 05:39PM
3277
July 27, 2010 06:36AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.