如何在使用phpmyadmin导入时忽略双引号?

时间:2012-02-06 07:51:02

标签: php mysql phpmyadmin mysqldump

我有一个看起来像这样的文件

"1106837", "Jabbar", "33.29106", "73.48639", "PK", "Asia/Karachi"
"1106838", "Dhangdev Saiyidān", "33.26424", "73.41412", "PK", "Asia/Karachi"
"1106839", "Dheriān", "33.255", "73.42722", "PK", "Asia/Karachi"
.
.
.

使用phpmyadmin导入文件后执行以下语句。

LOAD DATA INFILE  'C:\\wamp\\tmp\\phpC108.tmp' INTO TABLE  `allcountries` FIELDS 
TERMINATED BY  ',' ENCLOSED BY  '"' ESCAPED BY  '\\' LINES TERMINATED BY  '\r\n'(
`geonameid` ,  `place_name` ,  `lat` ,  `lng` ,  `country_code` ,  `city`

问题是双引号()也插入到表格列中。我不需要双引号

2 个答案:

答案 0 :(得分:0)

从文本文件中删除空格,mysql客户端无法解析它们。

"1106837", "Jabbar", "33.29106", "73.48639", "PK", "Asia/Karachi"

=>

"1106837","Jabbar","33.29106","73.48639","PK","Asia/Karachi"

答案 1 :(得分:0)

这是因为你的字段没有被,终止,它们被终止(终止字符串中有额外的空格)。请尝试以下方法:

LOAD DATA INFILE  'C:\\wamp\\tmp\\phpC108.tmp' INTO TABLE  `allcountries` FIELDS 
TERMINATED BY  ', ' ENCLOSED BY  '"' ESCAPED BY '\\' LINES TERMINATED BY  '\r\n'(
`geonameid` ,  `place_name` ,  `lat` ,  `lng` ,  `country_code` ,  `city`)