LOAD DATA INLINE
Overview
The LOAD DATA INLINE syntax can import strings organized in the csv format into the data table, and the import speed is faster than the INSERT operation.
Syntax Structure
mysql> LOAD DATA INLINE
FORMAT='csv',
DATA=$XXX$
csv_string $XXX$
INTO TABLE tbl_name;
Parameter explanation
FORMAT='csv' means that the string data in the following DATA is organized in the format csv.
DATA=$XXX$ in csv_string $XXX$is the identifier of the start and end of the data.csv_stringis to organize string data incsvas the format, with\nor\r\n` as the newline character.
Note
$XXX$ is the identifier of the start and end of the data. Note that $XXX$ at the end of the data needs to be placed in the same line as the last line. A line break may cause ERROR 20101
Example: Import data using LOAD DATA INLINE
-
Before executing
LOAD DATA INLINE, you need to create a complete data table in the database in advanceuser:CREATE TABLE `user` ( `name` VARCHAR(255) DEFAULT null, `age` INT DEFAULT null, `city` VARCHAR(255) DEFAULT null ) -
Execute
LOAD DATA INLINEon the MySQL client to import data, and import data in csv format:mysql> LOAD DATA INLINE FORMAT='csv', DATA=$XXX$ Lihua,23,Shanghai Bob,25,Beijing $XXX$ INTO TABLE user;
csv_string format requirements
| Characters | Description |
| -------------------------------------------------------------------------------------------------------------------------------
| Field splitter | Default ',' |
| Line ending character | \r\n or '\n' |