I have a problem with the importing of a CSV file to my table in MySQL. The values (3) of the columns (var1, var2, dates)
are not loading, as shown in the image below:
First I created the table,
CREATE TABLE table1 (
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
var1 INT NOT NULL,
var2 INT NOT NULL,
dates DATE NOT NULL
);
After that, I imported the data to the table:
LOAD DATA LOCAL INFILE '/home/task.csv'
INTO TABLE table1
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
ESCAPED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 LINES;
I am using an Ubuntu terminal.
Best Answer
Specify the column list so you won't include
id
. Add this after thenIGNORE
clause: