Skip to content

LINES

CREATE TABLE example_table(
id INT AUTO_INCREMENT,
text VARCHAR(100),
PRIMARY KEY(id)
);
LOAD DATA LOCAL INFILE 'file.txt' INTO TABLE example_table
LINES TERMINATED BY '\n'
(text);
Query OK, 3 rows affected (0.03 sec)

This code creates a new table example_table with two columns id and text. Then it loads data from a local file 'file.txt'. Each line in the input file is considered as a new record. Therefore the LINES TERMINATED BY '\n' clause is used to indicate end of a record.