Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Load Data Infile - edit a field
- Michael Blair
January 18, 2006, 2:35 am
rate this thread
Re: Load Data Infile - edit a field
There's no field-editing facility in LOAD DATA INFILE.
One solution would be:
1. Create your table with a CHAR field instead of a DATE field.
2. Load the data as is into the CHAR field.
3. Add a new DATE field.
4. Use UPDATE to set the DATE field based on the value in the CHAR field,
using an expression using the builtin STR_TO_DATE() function:
UPDATE myTable SET dateField = STR_TO_DATE(charField, '%m/%d/%Y');
5. Drop the old CHAR field.
Another option would be to use Perl or a text editor to reformat the dates
in the input file before you load it.
- » Americanas.com SALDO de TVs Com at 80% de Desconto (29798)
- — Newest thread in » MySQL Database Forum