LOAD DATA INFILE期间的SET将数据加载到错误的列

时间:2018-11-24 19:34:48

标签: mysql

这是我的代码:

Create Table Crime(
CrimeDate Date,
CrimeTime Date,
crimecode VARCHAR(3),
addr_line_1 varchar(50),
Description varchar(30),
Inside_Outside varchar(1),
Weapon varchar(20),
Post INT,
Neighborhood varchar(25),
longitude varchar(30),
Latitude varchar(30),
location varchar(100),
Premise varchar(25),
crimecase varchar(25),
Total_incident int
)
;

LOAD DATA INFILE 'BPD_Part_1_Victim_Based_Crime_Data.csv' INTO TABLE Crime
FIELDS TERMINATED BY ',' 
LINES TERMINATED BY '\n'
IGNORE 1 LINES
(@CrimeDate, @CrimeTime, crimecode, addr_line_1, Description, Inside_Outside, Weapon, Post, Neighborhood, longitude, latitude, location, premise, crimecase, total_incident)
SET 
    CrimeDate = STR_TO_DATE(@CrimeDate,'%d/%M/%y'), 
    CrimeTime = STR_TO_Date(@CrimeTime, '%H:%i:%S')
;

Data file is here if you're interested

我正在做的就是尝试将文件加载到表中,并告诉MySQL将CrimeDate和CrimeTime列解释为适当的Date字段。我知道我的STR_TO_DATE正确。

但是,当我运行此命令时,CrimeDate列显示为所有Null,CrimeTime列的结尾处是我试图分配给CrimeDate的值,并且无法找到CrimeTime值。

我在这里做错了什么?我在MySQL文档中看不到任何东西可以告诉我wtf列未正确加载。

0 个答案:

没有答案