我有一张表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
。