LOAD DATA INFILE
Syntax
1077
3,"a string containing a " quote",102.20
4,"a string containing a ", quote and comma",102.20
For input, the
ENCLOSED BY
character, if present, is stripped from the ends of field values. (This is true
regardless of whether
OPTIONALLY
is specified;
OPTIONALLY
has no effect on input interpretation.)
Occurrences of the
ENCLOSED BY
character preceded by the
ESCAPED BY
character are interpreted
as part of the current field value.
If the field begins with the
ENCLOSED BY
character, instances of that character are recognized as
terminating a field value only if followed by the field or line
TERMINATED BY
sequence. To avoid
ambiguity, occurrences of the
ENCLOSED BY
character within a field value can be doubled and are
interpreted as a single instance of the character. For example, if
ENCLOSED BY '"'
is specified,
quotation marks are handled as shown here:
"The ""BIG"" boss" -> The "BIG" boss
The "BIG" boss -> The "BIG" boss
The ""BIG"" boss -> The ""BIG"" boss
FIELDS ESCAPED BY
controls how to read or write special characters:
• 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 (Z)
\N
NULL
For more information about “
\
”-escape syntax, see
Section 9.1.1, “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:
• The
FIELDS ESCAPED BY
character
• The
FIELDS [OPTIONALLY] ENCLOSED BY
character
• The first character of the
FIELDS TERMINATED BY
and
LINES TERMINATED BY
values
• ASCII
0
(what is actually written following the escape character is ASCII “
0
”, not a zero-valued
byte)
If the
FIELDS ESCAPED BY
character is empty, no characters are escaped and
NULL
is output as
NULL
, not
\N
. It is probably not a good idea to specify an empty escape character, particularly if field
values in your data contain any of the characters in the list just given.
In certain cases, field- and line-handling options interact:
• If
LINES TERMINATED BY
is an empty string and
FIELDS TERMINATED BY
is nonempty, lines are
also terminated with
FIELDS TERMINATED BY
.
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...