Comments - Table Construction

4 years, 4 months ago Robert Wilson

CREATE TABLE EmployeeEvals (EmployeeNum INT(7) NOT NULL, Grade ENUM("PR", "SA", "UN", "VG", "EX"), Comment TEXT, EvaluatorNum INT(7) NOT NULL AUTO_INCREMENT PRIMARY KEY); Query OK, 0 rows affected (0.023 sec)

rwilson7 [Final6];LOAD DATA INFILE 'EmployeeEvals.csv' INTO TABLE EmployeeEvals -> FIELDS TERMINATED BY ',' -> ENCLOSED BY '"' -> LINES TERMINATED BY '\r\n' -> IGNORE 1 LINES; ERROR 1062 (23000): Duplicate entry '2' for key 'PRIMARY'

 
4 years, 4 months ago Ian Gilfillan

A primary key must be unique. This error means there are duplicate values for that field in the csv, which is not permitted according to your table definition. See Getting Started with Indexes. Also, check the csv data carefully. If your Comment field has commas in the text, this may be read as a field terminator, so these need to be escaped.

 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.