我正在尝试将csv文件加载到我的表中。我运行以下代码抛出错误
LOAD DATA LOCAL INFILE 'info.csv' INTO TABLE tbl_countryip (ipstart, ipend, countrycode) FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n' ;
错误是
bash: syntax error near unexpected token `('
我甚至在删除了tablename和column name之间的空格后尝试了但仍然是同样的错误 提前致谢
答案 0 :(得分:1)
试试这个语法 -
LOAD DATA LOCAL INFILE 'info.csv'
INTO TABLE tbl_countryip
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES
(col1, col2, col3, col4, col5...);
希望以下参考链接可以帮助您
答案 1 :(得分:0)
您需要进行以下更改:
\r
醇>
更新了查询
LOAD DATA LOCAL INFILE 'info.csv'
INTO TABLE tbl_countryip
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
如果您的csv文件中的第一行是列名,请在IGNORE 1 LINES
之后使用LINES TERMINATED
。