On Aug 4, 2009, at 5:44 PM, Craig White wrote:

I need to update almost all (but not quite all) records in a data table because the dates were imported like '08/04/09' instead of '2009-08-04'

I am looking at the mysql reference manual but it doesn't appear that it
would be easy to script a line by line 'update' from a csv file.

Now I still have the csv files (and a copy with the dates fixed) and I
suppose I could 'find', 'delete' and then 'import' again but there are
relational records so mysql would probably prevent me from doing that
unless I suspend all relational checks when I delete those records prior
to reimporting them with the fixed dates.

What's the best way to accomplish this?

Craig

I'm not sure if this helps, but MySQL has a 'csv' storage engine. This allows you to load a CSV file as a table like any other in the database. Once loaded, you can move the data to another table with something like 'INSERT INTO real_table SELECT * FROM csv_table'. Or, perhaps in your case a multi-table update from the CSV file to your target table might do the trick.

http://dev.mysql.com/doc/refman/5.0/en/csv-storage-engine.html

alex

Attachment: PGP.sig
Description: This is a digitally signed message part

---------------------------------------------------
PLUG-discuss mailing list - PLUG-discuss@lists.plug.phoenix.az.us
To subscribe, unsubscribe, or to change your mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss

Reply via email to