mysql error“无法识别的语句类型(接近终止于“

osh3o9ms  于 2021-06-18  发布在  Mysql
关注(0)|答案(1)|浏览(383)

我有mysql版本5.7.19,我正在尝试运行:

load data infile 'C:\projects\v1.csv' into table ups terminated by ',' lines terminated by '\n' (company,ups_name,ups_ip,ups_mac,community,type_id,mdm_mac,ter_dir,td,cty,city,location,address,is_active,connected_device_name,connected_device_type,on_id,optical_node,inserted,updated);

但是得到一个错误:

unrecognized statement type. (near terminated by)

# 1064 - You have an error in your SQL syntax; check

the manual that corresponds to your MySQL server version 
for the right syntax to use near 'terminated by ','
lines terminated by '\n' (company,ups_name,ups_ip,ups_mac,comm' at line 1

我检查了一下语法是否正确。我搞不懂怎么了?谢谢

tsm1rwdh

tsm1rwdh1#

如果您仔细阅读文档,您可以在 FIELDS 是可选的,如果您承诺使用该选项,则必须包括该部分:

LOAD DATA INFILE 'C:\projects\v1.csv' INTO TABLE ups
  FIELDS TERMINATED BY ','
  LINES TERMINATED BY '\n'
    (company,ups_name,ups_ip,ups_mac,community,type_id,mdm_mac,ter_dir,td,cty,city,location,address,is_active,connected_device_name,connected_device_type,on_id,optical_node,inserted,updated);

如果没有这一点,就不清楚什么是被终止的, FIELDS 或者 LINES ,因为两者都有 TERMINATED BY 组件。
具体来说 {FIELDS | COLUMNS} 符号表示其中之一,不是可选的。

相关问题