Jump to Navigation

051 - Importing Data in Bulk

Often, when setting up a new database, you will need to migrate data from an old database to MySQL.
To do that, you can use LOAD DATA INFILE for a lot of data. You can use this statement to import organized
data from a text file into a table in MySQL.

Example:

LOAD DATA INFILE '/tmp/data.txt' REPLACE INTO TABLE authors
CHARACTER SET utf8
FIELD TERMINATED BY '|' LINES TERMINATED BY '\r\n'
TEXT_FILEDS(col1, col2, col3, col4, col5)
SET author_last = col3, author_first = col4
IGNORE col1, col2, col5, 1 LINES;

 

MySQL:


Main menu 2

Story | by Dr. Radut