
character-set, regardless of the column data type. To properly interpret file
contents, you must ensure that it was written with the correct character-set.
If you write a data file with mysqldump -T or with the SELECT INTO OUTFILE
statement with the mysql client, be sure to use the --default-character-set
option, so that the output is written with the desired character-set.

When using mixed character sets, use the CHARACTER SET clause in both SELECT
INTO OUTFILE and LOAD DATA INFILE to ensure that MariaDB correctly interprets
the escape sequences.

The character_set_filesystem system variable controls the interpretation of
the filename.

It is currently not possible to load data files that use the ucs2 character
set.

Preprocessing Inputs
--------------------

col_name_or_user_var can be a column name, or a user variable. In the case of
a variable, the SET statement can be used to preprocess the value before
loading into the table.

Priority and Concurrency
------------------------

In storage engines that perform table-level locking (MyISAM, MEMORY and
MERGE), using the LOW_PRIORITY keyword, MariaDB delays insertions until no
other clients are reading from the table. Alternatively, when using the MyISAM
storage engine, you can use the CONCURRENT keyword to perform concurrent
insertion.

The LOW_PRIORITY and CONCURRENT keywords are mutually exclusive. They cannot
be used in the same statement.

Progress Reporting
------------------

The LOAD DATA INFILE statement supports progress reporting. You may find this
useful when dealing with long-running operations. Using another client you can
issue a SHOW PROCESSLIST query to check the progress of the data load.

Using mariadb-import/mysqlimport
--------------------------------

MariaDB ships with a separate utility for loading data from files:
mariadb-import (or mysqlimport before MariaDB 10.5). It operates by sending
LOAD DATA INFILE statements to the server.

Using mariadb-import/mysqlimport you can compress the file using the
--compress option, to get better performance over slow networks, providing
both the client and server support the compressed protocol. Use the --local
option to load from the local file system.

Indexing
--------

In cases where the storage engine supports ALTER TABLE... DISABLE KEYS
statements (MyISAM and Aria), the LOAD DATA INFILE statement automatically
disables indexes during the execution.

Examples
--------

You have a file with this content (note the the separator is ',', not tab,
which is the default):

2,2
3,3
4,4
5,5
6,8

CREATE TABLE t1 (a int, b int, c int, d int, PRIMARY KEY (a));
LOAD DATA LOCAL INFILE 
 '/tmp/loaddata7.dat' INTO TABLE t1 FIELDS TERMINATED BY ',' (a,b) SET c=a+b;
SELECT * FROM t1;
+------+------+------+
| a    | b    | c    |
+------+------+------+
|    2 |    2 |    4 |
|    3 |    3 |    6 |
|    4 |    4 |    8 |
|    5 |    5 |   10 |
|    6 |    8 |   14 |
+------+------+------+

Another example, given the following data (the separator is a tab):

1       a
2       b

The value of the first column is doubled before loading:

LOAD DATA INFILE 'ld.txt' INTO TABLE ld (@i,v) SET i=@i*2;

SELECT * FROM ld;
+------+------+
| i    | v    |
+------+------+
|    2 | a    |
|    4 | b    |
+------+------+

URL: https://mariadb.com/kb/en/load-data-infile/