Du kan angive kolonnerne og markere de unødvendige kolonner som '@dummy'.
LOAD DATA INFILE 'data.csv'
INTO TABLE t1
(column1, @dummy, column2, @dummy, @dummy, @dummy, @dummy, @dummy, @dummy, @dummy)
FIELDS TERMINATED BY '\t' ENCLOSED BY
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES;
Erstat t1
, column1
og column2
som du vil. For at indstille andre kolonner, som ikke er i datafilen, kan du gøre det sådan her:
LOAD DATA INFILE 'data.csv'
INTO TABLE t1
(column1, @dummy, column2, @dummy, @val, @dummy, @dummy, @dummy, @dummy, @dummy)
FIELDS TERMINATED BY '\t' ENCLOSED BY
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES
SET column3 = "test", column4 = CURRENT_TIMESTAMP, column5 = @val/10;
For yderligere reference anbefaler jeg, at du tager et kig på MySQL-reference .