ENCLOSED BY

ENCLOSED BY is a keyword used in SQL that indicates the character or characters that surround a field value in a CSV or similarly structured data file during the operation of data import or export. It is often used in the LOAD DATA INFILE statement and the FIELDS clause.

Example

LOAD DATA INFILE 'path/to/your/csv'
INTO TABLE your_table
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';

Output

Query OK, 20 rows affected (0.01 sec)
Records: 20 Deleted: 0 Skipped: 0 Warnings: 0

Explanation

The above SQL code is loading data from a CSV file into a MySQL table. The ENCLOSED BY '"' keyword is used to indicate that the values inside the file are enclosed by double quotes. It ensures that these quoted values are treated as single entities even if they contain the field terminator character (in this case, a comma).

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.