如何将csv文件中的数据导入到mysql数据库中?
有没有查询或其他可用的方式?
我想你的意思是 IMPORT
,这是如何实现的:
load data local infile 'yourCSVfilepath.csv' into table tableNameHERE
fields terminated by ','
optionally enclosed by '"'
lines terminated by '\r\n'
要从Mysql导出数据到csv,请使用以下代码:
SELECT *
INTO OUTFILE '/tmp/tablename.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM tablename
要将CSV导入MySQL,请使用以下内容
LOAD DATA INFILE 'c:/tablename.csv' INTO TABLE tablename