LOAD DATA [low_priority] [LOCAL] INFILE ' file_name.txt ' [REPLACE | IGNORE]
Into TABLE tbl_name
[Fields
[TERMINATED by ' \ t ']
[Optionally] Enclosed by "]
[escaped by ' \ \ ']
[LINES TERMINATED by ' \ n ']
[IGNORE number LINES]
[(Col_name,...)]
Custom syntax
The general rules of use for fields and lines are (in the process of importing and exporting, the symbols must be the same)
Load Data InFile ' c:/data.txt ' into Table ' tabletest ' fields Terminated by ', ' enclosed by ' "' escaped by '" ' Lines Termina Ted by ' \ r \ n ';
Fields Terminated by ', ' enclosed by ' "' escaped by '" '
Indicates that each field is separated by commas and the contents are enclosed in double quotation marks
Lines Terminated by ' \ r \ n ';
Indicates that each piece of data is separated by a newline character.
The Replace and Ignore keywords control the repetitive processing of existing unique key records. If you specify replace, the new row replaces the existing rows that have the same unique key value. If you specify ignore, skip the input of the duplicate rows of existing rows that have unique keys. If you do not specify an option, when a duplicate key is found, an error occurs, and the remainder of the text file is ignored
If you do not specify a fields clause, the default value is the same as if you write:
Fields TERMINATED by ' \ t ' enclosed by ' \ escaped by ' \ \ '
If you do not specify a lines clause, the default value is the same as if you write:
LINES TERMINATED by ' \ n '
The general rules of use for fields and lines are (in the process of importing and exporting, the symbols must be the same)
In other words, the default value causes the input to be read, and the LOAD DATA infile behaves as follows:
Look for row boundaries at line breaks
To divide rows into fields at a locator
Do not expect fields to be encapsulated by any quotation mark characters
A locator, line feed, or "\" that begins with "\" is interpreted as part of the literal character of the field value.
MySQL LOAD DATA infile parsing