我在使用 LOAD DATA INFILE 命令时遇到了一些麻烦,因为我想忽略数据库中已经存在的行。如果我有一个包含如下数据的表,
id |name |age
--------------------
1 |aaaa |22
2 |bbbb |21
3 |bbaa |20
4 |abbb |22
5 |aacc |22
其中 id 是自动增量值。我拥有的 csv 文件包含如下数据,
"cccc","14"
"ssee","33"
"dddd","22"
"aaaa","22"
"abbb","22"
"dhgg","34"
"aacc","22"
我想忽略行,
"aaaa","22"
"abbb","22"
"aacc","22"
并将其余的上传到表中。我尚未将所有内容上传到表的查询如下,
LOAD DATA INFILE 'member.csv'
INTO TABLE tbl_member
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '"'
LINES TERMINATED BY '\n'
(name, age);
请帮助我完成这项任务..将不胜感激..我尝试了很多链接但没有帮助:(