# **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

```text
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_string` is to organize string data in `csv` as the format, with `\n` or `\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`

1. Before executing `LOAD DATA INLINE`, you need to create a complete data table in the database in advance `user`:

    ```mysql

    CREATE TABLE `user` (
    `name` VARCHAR(255) DEFAULT null,
    `age` INT DEFAULT null,
    `city` VARCHAR(255) DEFAULT null
    )
    ```

2. Execute `LOAD DATA INLINE` on the MySQL client to import data, and import data in *csv* format:

    ```mysql
    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' |

<!-- etc. support json

mysql> LOAD DATA INLINE
FORMAT=('csv'|'json'),
DATA=$XXX$
(csv_string| json_string) $XXX$
INTO TABLE tbl_name;

-->
