0

I'm using the MySQL LOAD DATA LOCAL INFILE command to load a tab delimited text file. But when I include the column list I get an error code 1064.

LOAD DATA LOCAL INFILE '/myfile.txt'
        INTO TABLE mytable 
        (column1, column2, column3)
        FIELDS TERMINATED by '\t'
        LINES TERMINATED BY '\n'
        IGNORE 10 LINES;

The non-column version works:

 LOAD DATA LOCAL INFILE '/myfile.txt'
        INTO TABLE mytable 
        FIELDS TERMINATED by '\t'
        LINES TERMINATED BY '\n'
        IGNORE 10 LINES;

What is causing the syntax error?

1 Answer 1

2

The error is being caused by the position of the column list, which should be in the last row, i.e.:

LOAD DATA LOCAL INFILE '/myfile.txt'
    INTO TABLE mytable 
    FIELDS TERMINATED by '\t'
    LINES TERMINATED BY '\n'
    IGNORE 10 LINES
    (column1, column2, column3);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.