首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为简单查询生成垃圾输出的MySQL?

为简单查询生成垃圾输出的MySQL?
EN

Stack Overflow用户
提问于 2012-01-09 11:59:37
回答 1查看 90关注 0票数 0

我有一个非常简单的MySQL表,它包含四个字段:

代码语言:javascript
复制
id (autonumbered)
controllerType
onInstructions
offInstructions

我用CSV文件中的数据加载了表。该文件如下所示:

代码语言:javascript
复制
10,GK 212-02,,
11,GK 212-02 ex,,
12,GK 212-04,,
13,GK 212-06,,
14,GK 212-06 x 2,,

我运行的查询如下所示:

代码语言:javascript
复制
load data local infile '/home/garfonzo/controllers.csv' into table systems_controller_type fields terminated by ',' lines terminated by '\n' (id, controllerType, onInstructions, offInstructions);

它将数据加载到表中,而不会出现警告:

代码语言:javascript
复制
Query OK, 42 rows affected (0.00 sec)
Records: 42  Deleted: 0  Skipped: 0  Warnings: 0

然后,当我运行一个select * from systems_controller_type时,我得到以下输出:

代码语言:javascript
复制
+----+-------------------------------+----------------+-----------------+
| 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,则会得到以下结果:

代码语言:javascript
复制
select * from systems_controller_type where id=3;
+----+----------------+----------------+-----------------+
| id | controllerType | onInstructions | offInstructions |
+----+----------------+----------------+-----------------+
               |ar    |                |
+----+----------------+----------------+-----------------+
1 row in set (0.00 sec)

知道是怎么回事吗??我在导入阶段做错了什么吗?

EN

回答 1

Stack Overflow用户

发布于 2012-01-09 12:21:14

尝试使用以下查询...(不更新自动增量列-希望您在创建表时设置了自动增量值) ..

将数据本地infile‘/home/garfonzo/Controlers.csv’加载到以',‘行结尾的表格systems_controller_type字段中(@dummy,controllerType,onInstructions,offInstructions);

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8783758

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档