我有一个非常简单的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)知道是怎么回事吗??我在导入阶段做错了什么吗?
发布于 2012-01-09 12:21:14
尝试使用以下查询...(不更新自动增量列-希望您在创建表时设置了自动增量值) ..
将数据本地infile‘/home/garfonzo/Controlers.csv’加载到以',‘行结尾的表格systems_controller_type字段中(@dummy,controllerType,onInstructions,offInstructions);
https://stackoverflow.com/questions/8783758
复制相似问题