LOAD DATA

Standard Example

LOAD DATA LOCAL INFILE '/data/data.txt' IGNORE INTO TABLE test CHARACTER SET 'utf8' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' (id, sid, asf);

If a data field contains special characters like separators and escapes, execute OPTIONALLY ENCLOSED BY '"' to enclose the field with double quotation marks ("").

Example:

The following data field contains separators (,) and is enclosed with quotation marks:

"aab,,,bba,ddd"

If a data field contains quotation marks, the preceding method may not work. You can add a backslash (\) before each quotation mark (") in the field, for example, "aab,,,bba,ddd\"ddd\"bb,ae".

  1. Importing data affects performance of DDM instances and RDS for MySQL instances. Import data during off-peak hours.
  2. Do not to send multiple LOAD DATA requests at the same time. If you do so, SQL transactions may time out due to highly concurrent data write operations, table locking, and system I/O occupation, resulting in failure of all LOAD DATA requests.
  3. Manually submit transactions when using LOAD DATA to import data so that data records are modified correctly.

    For example, configure your client as follows:

    mysql> set autocommit=0;

    mysql> LOAD DATA LOCAL INFILE '/data/data.txt' IGNORE INTO TABLE test CHARACTER SET 'utf8' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' (id, sid, asf);

    mysql> commit;

Use Constraints

There are the following constraints on LOAD DATA syntax.