mysql加载csv文件但没有双引号?

83qze16e  于 2021-06-19  发布在  Mysql
关注(0)|答案(1)|浏览(558)

我使用mysql加载csv文件,但是字符串列没有引号,所以我只得到值的第一个字母。

1,Toyota Park,Bridgeview,IL,0
2,Columbus Crew Stadium,Columbus,OH,0
3,RFK Stadium,Washington,DC,0

在我使用了这里的代码之后,我得到了:

LOAD DATA LOCAL INFILE 'C:\\Users\\tank\\Desktop\\test.csv'
INTO TABLE test
FIELDS TERMINATED BY ',' 
LINES TERMINATED BY '\n'
IGNORE 0 ROWS;

我有一张table:

+---------------------------------------------+
| ID, Studios, City, State, Open              |
+---------------------------------------------+
| '1', 'T', 'B', 'I', '0'                     |
| '2', 'C', 'C', 'O', '0'                     |
| '3', 'R', 'W', 'D', '0'                     |
+---------------------------------------------+
csbfibhn

csbfibhn1#

您应使用随函附上的:

LOAD DATA LOCAL INFILE 'C:\\Users\\tank\\Desktop\\test.csv'
INTO TABLE test
FIELDS TERMINATED BY ',' 
LINES TERMINATED BY '\n'
ENCLOSED BY '\"'
ESCAPED BY '\"'
IGNORE 0 ROWS;

相关问题