我有一个非常简单的MySQL表,包含四个字段:
id (autonumbered)
controllerType
onInstructions
offInstructions
我在表格中加载了CSV文件中的数据。该文件如下所示:
10,GK 212-02,,
11,GK 212-02 ex,,
12,GK 212-04,,
13,GK 212-06,,
14,GK 212-06 x 2,,
我运行的查询看起来像这样:
load data local infile '/home/garfonzo/controllers.csv' into table systems_controller_type fields terminated by ',' lines terminated by '\n' (id, controllerType, onInstructions, offInstructions);
它将数据加载到表中而没有任何警告:
Query OK, 42 rows affected (0.00 sec)
Records: 42 Deleted: 0 Skipped: 0 Warnings: 0
然后,当我运行select * from systems_controller_type
时,我得到了这个输出:
+----+-------------------------------+----------------+-----------------+
| id | controllerType | onInstructions | offInstructions |
+----+-------------------------------+----------------+-----------------+
| | |
| Plus | |
|ar | |
|ar exterior | |
|ird | |
| | |
| | |
| | |
| | |
| | |
| ex | |
| | |
| | |
| x 2 | |
| | |
|06 | |
| | |
| 06 | |
| | |
| | |
| | |
|el | |
|troller | |
| | |
|E-12 | |
|EC-9 | |
| | |
| | |
| | |
|nder (x2) | |
|- 9 station | |
| | |
|rollers | |
|Modular | |
| | |
| | |
|om Command (I think) | |
|lar | |
|mmand | |
| 04 04 04 | |
| | |
| | |
+----+-------------------------------+----------------+-----------------+
如果我为一条记录做了select
,我就明白了:
select * from systems_controller_type where id=3;
+----+----------------+----------------+-----------------+
| id | controllerType | onInstructions | offInstructions |
+----+----------------+----------------+-----------------+
|ar | |
+----+----------------+----------------+-----------------+
1 row in set (0.00 sec)
知道发生了什么事吗?我是否在进口阶段做错了什么?
答案 0 :(得分:0)
尝试使用以下查询...(不更新自动增量列 - 希望您在创建表时设置自动增量值)..
将数据本地infile'/home/garfonzo/controllers.csv'加载到表systems_controller_type字段中,以','以'\ n'结尾的行终止(@dummy,controllerType,onInstructions,offInstructions);