I have a mysql table with a column named date of TIMESTAMP type. I'm trying to load big amount of data using LOAD DATA LOCAL INFILE. Everything works, except that the date column cant be filled with a custom unix timestamp created from a string. Here is the SQL query:
LOAD DATA LOCAL INFILE '/path/to/file.csv' INTO TABLE names FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' (@nm) set `name`=@nm, `gender`='female', `date`=UNIX_TIMESTAMP(STR_TO_DATE('2015-06-07 09:21:44', '%Y-%m-%d %H:%i:%s'));
Also tryed this:
LOAD DATA LOCAL INFILE '/path/to/file.csv' INTO TABLE names FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' (@nm) set `name`=@nm, `gender`='female', `date`=UNIX_TIMESTAMP('2015-06-07 09:21:44');
The problem is, that the date field is filled with 0000-00-00 00:00:00 .
Have anybody any idea what can be the problem?
UNIX_TIMESTAMPdata type, do you meanTIMESTAMP?UNIX_TIMESTAMPandSTR_TO_DATEfunction.TIMESTAMPfields work with theyyyy-mm-dd hh:mm:ssformat (same asDATETIME).