日期:2014-05-16  浏览次数:20755 次

MySQL中导入CSV格式数据的SQL语句

sql如下:

?

load data infile '/tmp/test.csv' 
into table test_info  
fields terminated by ','  optionally enclosed by '"' escaped by '"' 
lines terminated by '\r\n';

?

(1)字段之间以逗号分隔,数据行之间以\r\n分隔;

(2)字符串以半角双引号包围,字符串本身的双引号用两个双引号表示。