I'm facing an issue while importing a .csv file into a MySQL table.
mysql> LOAD DATA INFILE '/var/lib/mysql-files/script_output.csv'
REPLACE INTO TABLE incidents columns terminated by ',' optionally
enclosed by '"' ignore 1 lines;
ERROR 1292 (22007): Incorrect datetime value: '2021-08-29T04:18:35Z' for column 'incident_start' at row 1
But, I can import without an issue with IGNORE command.
mysql> LOAD DATA INFILE '/var/lib/mysql-files/script_output.csv'
IGNORE INTO TABLE incidents columns terminated by ',' optionally
enclosed by '"' ignore 1 lines;
Query OK, 0 rows affected, 809 warnings (0.01 sec) Records: 266 Deleted: 0 Skipped: 266 Warnings: 809
My requirement is to replace/update the columns in case any update on previous values in the table.
Table Structure
+----------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+--------------+------+-----+---------+-------+
| incident | varchar(12) | NO | PRI | NULL | |
| description | varchar(300) | YES | | NULL | |
| status | varchar(12) | YES | | NULL | |
| urgency | varchar(7) | YES | | NULL | |
| service | varchar(27) | YES | | NULL | |
| trigger | varchar(25) | YES | | NULL | |
| team | varchar(20) | YES | | NULL | |
| incident_start | datetime(6) | YES | | NULL | |
| incident_end | datetime(6) | YES | | NULL | |
| resolved_by | varchar(20) | YES | | NULL | |
+----------------+--------------+------+-----+---------+-------+
How we can fix the issue of Incorrect datetime while importing .csv with replace option?
TandZcharacters from dates), then using the updated output as the source ...