编译器说语法错误接近“FIELDS TERMINATED .....”
LOAD DATA LOCAL INFILE '/Data/books.csv'
INTO TABLE Book
IGNORE 1 LINES
(@col1,@col2,@dummy,@dummy,@dummy,@dummy,@dummy,@dummy)
set Book_id=@col1,Title=@col2
FIELDS TERMINATED BY '\t'
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
答案 0 :(得分:3)
这是因为您拥有列列表并在fields子句之前设置。当没有遇到字段行时,Mysql将使用默认值然后处理col列表,然后在遇到fields子句时抛出错误。试试这个
LOAD DATA LOCAL INFILE '/Data/books.csv'
INTO TABLE Book
FIELDS TERMINATED BY '\t'
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 LINES
(@col1,@col2,@dummy,@dummy,@dummy,@dummy,@dummy,@dummy)
set Book_id=@col1,Title=@col2