官方文档:dev.mysql.com/doc/refman/5.1/zh/sql-syntax.html
使用语句 load data infile 该语句能高速的从一文本文件中提取行并导入数据表中。
load data infile 语法格式:
load data [low_priority ] infile '文本文件路径' [replace | ignore ] into table tableName
character set utf8 [fields [terminated by ' string ' ] ] [ lines [ starting by 'string']
[terminated by 'string'] (` 字段一`,`字段二`...)
解释:
low_priority 降低语句的执行优先级,当客户端不从表中取数据时在执行。
replace | ignore 对于主索引和唯一索引具有相同值的记录,replace选项会替换原有的记录,ignore则忽略。
character set 设定编码
fields terminated by ‘string' 字段以什么间隔
lines tiermnated by 'string' 记录以什么间隔
(`字段一`,`字段二`..)将文本文件按列赋值给表中的字段