LOAD DATA INFILE 'filename.csv' INTO TABLE table_name
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\n' IGNORE 1 LINES
(Date,col2,col3,col4,col5,col6,col7,@dummy_variable)
Set dummy_variable = 0
加载正常,但日期格式显示为0000-00-00
csv中的日期采用[{1}}样式,无法在csv文件中更改。
答案 0 :(得分:1)
您需要使用str_to_date
下面的内容应该有效。
LOAD DATA INFILE 'filename.csv' INTO TABLE table_name
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\n' IGNORE 1 LINES
(@myDate,col2,col3,col4,col5,col6,col7,@dummy_variable)
Set dummy_variable = 0, Date = str_to_date(@myDate,'%d/%m/%Y')