为什么在尝试将.csv文件导入MariaDB表时会收到此错误消息?

时间:2020-03-01 20:02:58

标签: mysql database mariadb rdbms csv-import

我正在尝试将 .csv 文件内容导入到 Maria DB 表中,但是发现了一些困难。我正在研究Linux Ubuntu环境。

我有以下情况。这是我的状态表:

MariaDB [Delphys]> describe Status;
+-------------+--------------+------+-----+---------+----------------+
| Field       | Type         | Null | Key | Default | Extra          |
+-------------+--------------+------+-----+---------+----------------+
| StatusID    | int(11)      | NO   | PRI | NULL    | auto_increment |
| Status      | char(1)      | YES  |     | NULL    |                |
| StatusGroup | char(3)      | YES  |     | NULL    |                |
| text        | varchar(255) | YES  |     | NULL    |                |
| TestText01  | varchar(255) | YES  |     | NULL    |                |
| TestText02  | varchar(255) | YES  |     | NULL    |                |
+-------------+--------------+------+-----+---------+----------------+
6 rows in set (0.106 sec)

这是我要导入到上表中的文件的内容:

1;A;ABC;Existing sensors, already linked to DCS/DeltaV;Defalt value;Simulated input value
2;B;ABC;Existing sensors, already linked to DCS to be linked to DeltaV;Simulated value;Simulated input value
3;C;ABC;Sensors to be installed and linked to DCS/DeltaV;Simulated value;Simulated input value
4;D;D  ;Calculated Value without Model and GPA;expected result without Model and GPA;expected result without Model and GPA
5;E;E  ;Calculated Values after Establishment of Engine Model and GPA;expected result after Establishment of Engine Model and GPA;expected result after Establishment of Engine Model and GPA

我在MariaDB控制台中执行了以下命令,并获得以下错误消息:

MariaDB [Delphys]> LOAD DATA INFILE '/var/lib/mysql/Status.csv'
    -> INTO TABLE Status
    -> FIELDS TERMINATED BY ';' 
    -> LINES TERMINATED BY '\n'
    -> ;
ERROR 1366 (22007): Incorrect integer value: '??1' for column `Delphys`.`Status`.`StatusID` at row 1

一个疑问是我的 .csv 文件是由Windows计算机生成的,它可能以不同的方式处理换行符(但对我来说似乎很奇怪)。

怎么了?我想念什么?如何正确导入 .csv 文件?

1 个答案:

答案 0 :(得分:1)

您缺少INTO TABLE table,即CSV文件应插入到哪个表中。