Mysql 为什么我的;空";tsv的日期时间条目是否转换为0000-00-00:00:00?
最近在x86_64(自制)上为osx10.15更新了mysql 8.0.19版 我正在尝试从tsv文件加载数据,以便将条目添加到现有表中。一切似乎都很正常,除了“NULL”的值(字面意思是,它不是空的)正在转换为0000-00-00:00:00。没有错误,但我确实收到警告“第2行'Beginep'列的数据被截断” 以下是我尝试过的,但没有用:Mysql 为什么我的;空";tsv的日期时间条目是否转换为0000-00-00:00:00?,mysql,csv,datetime,null,truncated,Mysql,Csv,Datetime,Null,Truncated,最近在x86_64(自制)上为osx10.15更新了mysql 8.0.19版 我正在尝试从tsv文件加载数据,以便将条目添加到现有表中。一切似乎都很正常,除了“NULL”的值(字面意思是,它不是空的)正在转换为0000-00-00:00:00。没有错误,但我确实收到警告“第2行'Beginep'列的数据被截断” 以下是我尝试过的,但没有用: ALTER TABLE infomegatask ALTER beginexp SET DEFAULT NULL; # same for field '
ALTER TABLE infomegatask
ALTER beginexp SET DEFAULT NULL; # same for field 'endhit'
ALTER TABLE infomegatask MODIFY COLUMN beginexp DATETIME NULL; #even though it was already nullable to begin with when I checked the schema
#also set sql_mode="NO_ZERO_DATE"
以下是tsv外观的编辑片段(敏感数据已被掩盖):
我的意思是,我现在要做的解决方法是将这些零日期时间更新为NULL,但这有点烦人,我只想找出哪里出了问题。在语法中,您可以转换列
因此,在你的情况下:
LOAD DATA
INTO TABLE xx ( .., @beginexp , ... )
...
SET beginexp = IF(@beginexp='NULL', NULL, @beginexp),
...
mysql> LOAD DATA LOCAL INFILE 'test/DB/tsv/infomegatask_round_9g.tsv' INTO TABLE infomegatask FIELDS TERMINATED BY '\t' ENCLOSED BY '' LINES TERMINATED BY '\n' IGNORE 1 LINES;
Query OK, 24 rows affected, 13 warnings (0.21 sec)
Records: 24 Deleted: 0 Skipped: 0 Warnings: 13
mysql> warnings
Show warnings enabled.
mysql> show warnings
-> ;
+---------+------+------------------------------------------------+
| Level | Code | Message |
+---------+------+------------------------------------------------+
| Warning | 1265 | Data truncated for column 'beginexp' at row 2 |
| Warning | 1265 | Data truncated for column 'endhit' at row 2 |
| Warning | 1265 | Data truncated for column 'beginexp' at row 4 |
| Warning | 1265 | Data truncated for column 'endhit' at row 4 |
| Warning | 1265 | Data truncated for column 'beginexp' at row 7 |
| Warning | 1265 | Data truncated for column 'endhit' at row 7 |
| Warning | 1265 | Data truncated for column 'beginexp' at row 9 |
| Warning | 1265 | Data truncated for column 'endhit' at row 9 |
| Warning | 1265 | Data truncated for column 'beginexp' at row 10 |
| Warning | 1265 | Data truncated for column 'endhit' at row 10 |
| Warning | 1265 | Data truncated for column 'endhit' at row 14 |
| Warning | 1265 | Data truncated for column 'beginexp' at row 20 |
| Warning | 1265 | Data truncated for column 'endhit' at row 20 |
+---------+------+------------------------------------------------+
13 rows in set (0.00 sec)
LOAD DATA
INTO TABLE xx ( .., @beginexp , ... )
...
SET beginexp = IF(@beginexp='NULL', NULL, @beginexp),
...