Importing data from Sybase to MySQL

I'm migrating an old Sybase database to a new MySQL db. Since the moment that Sybase can export data to .dat files (something similar to new csv), I decided to use it.

The problem is that Sybase uses commas as column separator and commas in strings are ignored because are enclosed in '', but not in MySQL.

Is there a way to solve the problem? Here's my query:

LOAD DATA LOCAL INFILE 'C:\\UNLOAD\\166.dat'
INTO TABLE linea_col
COLUMNS TERMINATED BY ','
LINES TERMINATED BY '\r\n';

Thank you in advance.

Answers


If they are enclosed by single quotes try this:

LOAD DATA LOCAL INFILE 'C:\\UNLOAD\\166.dat'
INTO TABLE linea_col
COLUMNS TERMINATED BY ','
ENCLOSED BY '\''
LINES TERMINATED BY '\r\n';

If that doesn't work then you should do ENCLOSED BY '''' but I'm 99.99% certain the first is correct.


I'm not familiar with how DAT files may differ to CSV, but you can use CSV as the common format.

You can export from Sybase using BCP and forcing the output to use CSV format

bcp database.dbo.tbl_name out c:\temp\output.csv -c -t, -U user_name -P password -S server_name

Then import into MySQL with

load data local infile 'uniq.csv' into table tblUniq fields terminated by ','
enclosed by '"'
lines terminated by '\n'
(uniqName, uniqCity, uniqComments)

Need Your Help

Best way to retrieve certain field of all documents returned by a Lucene search

performance search lucene field documents

I was wondering what the best way is to retrieve a certain field of all documents returned by a Searcher of Lucene.

Multiple repeating broadcasts never get new extras

java android broadcastreceiver alarmmanager android-pendingintent

I have an app that schedules tweets at either given times or at set intervals. I use a repeating broadcastIntent to send the tweets. I include extras for the message, username, etc.