LOAD DATA Statement If the data file looks like this: xxx"abc",1 something xxx"def",2 "ghi",3 The resulting rows are  ("abc",1)  and  ("def",2) . The third row in the file is skipped because it does not contain the prefix. The  IGNORE  number  LINES  clause can be used to ignore lines at the start of the file. For example, you can use  IGNORE 1 LINES  to skip an initial header line containing column names: LOAD DATA INFILE ’/tmp/test.txt’ INTO TABLE test IGNORE 1 LINES; When you use  SELECT ... INTO OUTFILE  in tandem with  LOAD DATA  to write data from a database into a file and then read the file back into the database later, the field- and line-handling options for both statements must match. Otherwise,  LOAD DATA  does not interpret the contents of the file properly. Suppose that you use  SELECT ... INTO OUTFILE  to write a file with fields delimited by commas: To read the comma-delimited file, the correct statement is: If instead you tried to read the file with the statement shown following, it would not work because it instructs LOAD DATA  to look for tabs between fields: The likely result is that each input line would be interpreted as a single field. LOAD DATA  can be used to read files obtained from external sources. For example, many programs can export data in comma-separated values (CSV) format, such that lines have fields separated by commas and enclosed within double quotation marks, with an initial line of column names. If the lines in such a file are terminated by carriage return/newline pairs, the statement shown here illustrates the field- and line- handling options you would use to load the file: LOAD DATA INFILE ’data.txt’ INTO TABLE table2 FIELDS TERMINATED BY ’	’; LOAD DATA INFILE ’data.txt’ INTO TABLE table2 FIELDS TERMINATED BY ’,’; SELECT * INTO OUTFILE ’data.txt’ FIELDS TERMINATED BY ’,’ FROM table2; LOAD DATA INFILE ’data.txt’ INTO TABLE  tbl_name FIELDS TERMINATED BY ’,’ ENCLOSED BY ’"’ LINES TERMINATED BY ’\r
’ IGNORE 1 LINES; If the input values are not necessarily enclosed within quotation marks, use  OPTIONALLY  before the ENCLOSED BY  option. Any of the field- or line-handling options can specify an empty string ( ’’ ). If not empty, the  FIELDS [OPTIONALLY] ENCLOSED BY  and  FIELDS ESCAPED BY  values must be a single character. The FIELDS TERMINATED BY ,  LINES STARTING BY , and  LINES TERMINATED BY  values can be more than one character. For example, to write lines that are terminated by carriage return/linefeed pairs, or to read a file containing such lines, specify a  LINES TERMINATED BY ’\r
’  clause. To read a file containing jokes that are separated by lines consisting of  %% , you can do this CREATE TABLE jokes (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, joke TEXT NOT NULL); LOAD DATA INFILE ’/tmp/jokes.txt’ INTO TABLE jokes 2644