I am loading a CSV file into MySQL (5.1) using CREATE TABLE
and LOAD DATA
. I have a number of columns which are textual types (categories) but contain numerical values. When I create the table I assign these columns as VARCHAR(254)
but the JDBC driver throws a SQLException "Data truncated for column AgeGroup at row 1".
My data looks like this:
ID,AgeGroup
xxx,4
xxy,3
xyx,6
...
My create table statement looks like this
CREATE TABLE abc(ID VARCHAR(254), AgeGroup VARCHAR(254))
My load statement looks like this
LOAD DATA INFILE \myfile.csv\ INTO TABLE abc FIELDS TERMINATED BY ','
I am guessing that it is a type conversion issue because AgeGroup is a textual database column but I am sticking what appear to be numbers in it.
How do I - can I - force the LOAD DATA
command to honour the datatype of the column and convert the contents of the file?
I'm using the official MySQL JDBC Driver.