Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Can somebody please help me understand what is ESCAPED BY clause means in LOAD DATA LOCAL INFILE statement MySQL 5.5. I am a newbie to MySQL so please bear with me.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Generally the defaults cause LOAD DATA INFILE to act as follows when reading input:

Look for line boundaries at newlines.
Break lines into fields at tabs.
Do not expect fields to be enclosed within any quoting characters.
Interpret occurrences of tab, newline, or \' preceded by\' as literal characters that are part of field values.
Conversely, the defaults cause SELECT ... INTO OUTFILE to act as follows when writing output:

Write tabs between fields.
Do not enclose fields within any quoting characters.

Use \' to escape instances of tab, newline or\' that occur within field values.

Write newlines at the ends of lines.

Note that to write FIELDS ESCAPED BY '\\', you must specify two backslashes for the value to be read as a single backslash.

For Further Details Please Have a Look at following Link :- dev.mysql.com/doc/refman/5.1/en/load-data.html

share|improve this answer

For input, if the FIELDS ESCAPED BY character is not empty, occurrences of that character are stripped and the following character is taken literally as part of a field value. Some two-character sequences that are exceptions, where the first character is the escape character. These sequences are shown in the following table (using “\” for the escape character). The rules for NULL handling are described later in this section. Character Escape Sequence

\0 An ASCII NUL (0x00) character

\b A backspace character

\n A newline (linefeed) character

\r A carriage return character

\t A tab character.

\Z ASCII 26 (Control+Z)

\N NULL

“String Literals”.

If the FIELDS ESCAPED BY character is empty, escape-sequence interpretation does not occur



.For output, if the FIELDS ESCAPED BY character is not empty, it is used to prefix the following characters on output:

However

If FIELDS ESCAPED BY is empty, a field value that contains an occurrence of FIELDS ENCLOSED BY or LINES TERMINATED BY followed by the FIELDS TERMINATED BY value causes LOAD DATA INFILE to stop reading a field or line too early. This happens because LOAD DATA INFILE cannot properly determine where the field or line value ends.

Basically Escaped by is used to escape the column on the basis of charachters appearing in data if it's not required

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.