MySQL load data infile parsing, mysqlinfile
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 use rules of FIELDS and LINES are (the symbols after by must be consistent during the import and export processes)
Load Data InFile 'C:/Data.txt 'into table' tabletest' Fields Terminated By ', 'enabled' "'elasticed' By'" 'Lines Terminated By '\ r \ n ';
Fields Terminated By ', 'enabledby' "'escaped '"'
Each field is separated by a comma. The content is included in double quotation marks.
Lines Terminated By '\ r \ n ';
Indicates that each piece of data is separated by a line break.
The REPLACE and IGNORE keywords control repeated processing of existing unique key records. If you specify REPLACE, the new row replaces the existing row with the same unique key value. If you specify IGNORE, skip the input of duplicate rows of existing rows with a unique key. If you do not specify any option, an error occurs when the duplicate key is found and the remaining part of the text file is ignored.
If you do not specify a FIELDS clause, the default value is the same as if you write this statement:
Fields terminated by '\ t' enclosed by ''escaped '\\'
If you do not specify a LINES clause, the default value is the same as if you write this statement:
Lines terminated by '\ N'
The general use rules of FIELDS and LINES are (the symbols after by must be consistent during the import and export processes)
In other words, when the default value causes reading input, load data infile performs as follows:
Search for line boundary at line breaks
Split the row into fields at the location Operator
Do not expect fields to be enclosed by any quotation marks
The delimiters, linefeeds, or "\" starting with "\" are part of the literal characters of the field value.