分享csv导入数据到mysql实例

csv表中含有中文字符,具体实现代码示例:

load data infile ‘C:UsersAdministratorDesktopimportCELLutf.csv’ into table cell character set gbk(设置gbk字符编码,防止出现中文乱码)
fields terminated by ‘,’
enclosed by ‘”‘
lines terminated by ‘ ‘
IGNORE 1 LINES;

代码解释:

fields terminated by ‘,’:csv文件中数据之间的分隔符,csv文件默认以逗号分隔;

enclosed by ”:指出封套符;

lines terminated by ”:指行终止符;

IGNORE 1 LINES:忽略csv表头。

© 版权声明
THE END
喜欢就支持一下吧
点赞6 分享