top of page
CerebroSQL

MySQL: 

LOAD DATA

Syntax:
LOAD DATA
[LOW_PRIORITY | CONCURRENT] [LOCAL]
INFILE 'file_name'
[REPLACE | IGNORE]
INTO TABLE tbl_name
[PARTITION (partition_name [, partition_name] ...)]
[CHARACTER SET charset_name]
[{FIELDS | COLUMNS}
[TERMINATED BY 'string']
[[OPTIONALLY] ENCLOSED BY 'char']
[ESCAPED BY 'char']
]
[LINES
[STARTING BY 'string']
[TERMINATED BY 'string']
]
[IGNORE number {LINES | ROWS}]
[(col_name_or_user_var
[, col_name_or_user_var] ...)]
[SET col_name={expr | DEFAULT}
[, col_name={expr | DEFAULT}] ...]

The LOAD DATA statement reads rows from a text file into a table at a
very high speed. LOAD DATA is the complement of SELECT ... INTO
OUTFILE. (See
https://dev.mysql.com/doc/refman/8.0/en/select-into.html.) To write
data from a table to a file, use SELECT ... INTO OUTFILE. To read the
file back into a table, use LOAD DATA. The syntax of the FIELDS and
LINES clauses is the same for both statements.

You can also load data files by using the mysqlimport utility; see
https://dev.mysql.com/doc/refman/8.0/en/mysqlimport.html. mysqlimport
operates by sending a LOAD DATA statement to the server.

For more information about the efficiency of INSERT versus LOAD DATA
and speeding up LOAD DATA, see
https://dev.mysql.com/doc/refman/8.0/en/insert-optimization.html.

URL: https://dev.mysql.com/doc/refman/8.0/en/load-data.html

Example

bottom of page