/*
1.测试环境是windows,filepath需要用'\\',cmd中filepath可以有中文,navicat不支持中文
2.mysql默认EOL是'\n',windows需要指定为'\r\n',否则最后一列数据都会带'\r',db中看不出来,where clause匹配不到
3.字段分隔符:fields terminated必须在lines terminated之前,否则报错
4.ignore 1 lines不导入标题
5.速度:71万条记录,13个字段,一次37s,一次26s
*/
--windows下的正确写法
load data local infile 'G:\\temp\\我的数据.csv' into table table_name fields terminated by ',' lines terminated by '\r\n' ignore 1 lines;
--'\r'的处理
insert into table(col1,col2) values(1,'a\r'); --col2长度为2
update table col2=replace(col2,'\r','') where col1 = 1; --替换掉'\r'