为什么从文本文件到表中的LOAD DATA在mysql中无法正常工作?

时间:2016-09-12 09:33:33

标签: mysql sql database mysql-5.7

我有一张表event

+--------+--------------+------+-----+---------+-------+
| Field  | Type         | Null | Key | Default | Extra |
+--------+--------------+------+-----+---------+-------+
| name   | varchar(20)  | YES  |     | NULL    |       |
| date   | date         | YES  |     | NULL    |       |
| type   | varchar(15)  | YES  |     | NULL    |       |
| remark | varchar(255) | YES  |     | NULL    |       |
+--------+--------------+------+-----+---------+-------+

现在我希望从文本文件event.txt向此表中插入一些数据。文本文件为:

Tommy   2000-01-02  litter  4 kittens, 3 females, 1 male
Bowser  2001-04-26  vet needed break straightened
puffball    2002-05-13  birthday    gave him a new chew toy  

值之后的空格是制表符。最后的值是具有实际空格的句子。当我将此txt文件加载到表event时,它不会正确加载值。我运行查询:

load data local infile 'D:/Softwear/mysql/install/data/event.txt' into table event;

生成的表格如下:

+----------+------------+----------+-------------------------------+
| name     | date       | type     | remark                        |
+----------+------------+----------+-------------------------------+
 |Tommy    | 2000-01-02 | litter   | 4 kittens, 3 females, 1 male
    |ser   | 2001-04-26 | vet      | needed break straightened
| puffball | 2002-05-13 | birthday | gave him a new chew toy       |
+----------+------------+----------+-------------------------------+

bowser被截断。为什么会这样?当我将类似的pet.txt文件上传到表pet时,表格生成正确。我使用记事本来编写txt文件,在值之后使用tab,在行之后使用newline

0 个答案:

没有答案