Hi I am trying to add data to a table using mysql INFILE Command but getting the following error.
Warning (Code 1411): Incorrect datetime value: ''2015-05-15 15:57:46'' for function str_to_date
Warning (Code 1048): Column 'transaction_time' cannot be null
mysql -uroot test --show-warnings -vve "LOAD DATA INFILE '/Users/xyz/log2.tsv' into table logs_master fields terminated by '\t' enclosed by '' lines terminated by '\n' (@transaction_time, col2, col3, col4,...) SET updated_at = NOW(), transaction_time = STR_TO_DATE(@transaction_time, '%Y-%m-%d %H:%i:%s')"
CREATE TABLE `test_action_logs_master` (
`transaction_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`col1` varchar(100) DEFAULT NULL,
`col2` varchar(700) DEFAULT NULL,
`col3` varchar(700) DEFAULT NULL,
`col4` varchar(700) DEFAULT NULL,
`col5` varchar(200) DEFAULT NULL,
`col6` varchar(700) DEFAULT NULL,
`col7` varchar(700) DEFAULT NULL,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
KEY `col3` (`col3`),
KEY `col4` (`col4`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
mysql version: Server version: 5.6.25 Machine: OS X(MAC) Yosemite
show variables like 'sql_mode'
-> ;
+---------------+------------------------+
| Variable_name | Value |
+---------------+------------------------+
| sql_mode | NO_ENGINE_SUBSTITUTION |
+---------------+------------------------+
1 row in set (0.00 sec)
I have made the changes by looking at other threads on the issue and also looking at the link http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format
Somehow, it doesn't work and gives the listed error. The rest of the fields are sourced properly, just that the leading field which is a date time value is not getting sourced.