Tag Archives: mysql load into

MySQL LOAD DATA INFILE Syntax for Importing from CSV file.

The LOAD DATA INFILE statement reads rows from a text file into a table at a very high speed. LOAD DATA INFILE is the complement of SELECT … INTO OUTFILE. To write data from a table to a file, use SELECT … INTO OUTFILE. To read the file back into a table, use LOAD DATA INFILE. The syntax of the FIELDS and LINES clauses is the same for both statements. Both clauses are optional, but FIELDS must precede LINES if both are specified.

LOAD DATA INFILE CSV Example (MySQL CLI):

For a sucessful operation, The fields count in the CSV file should match with the column count of the table. Otherwise your operation result will be Invalid/Erroneous. Also path to the CSV file should be correctly specified.