(mysql.info) charset-literal
Info Catalog
(mysql.info) charset-column
(mysql.info) charset-syntax
(mysql.info) charset-national
10.3.5 Character String Literal Character Set and Collation
-----------------------------------------------------------
Every character string literal has a character set and a collation.
A character string literal may have an optional character set
introducer and `COLLATE' clause:
[_CHARSET_NAME]'STRING' [COLLATE COLLATION_NAME]
Examples:
SELECT 'STRING';
SELECT _latin1'STRING';
SELECT _latin1'STRING' COLLATE latin1_danish_ci;
For the simple statement `SELECT 'STRING'', the string has the
character set and collation defined by the `character_set_connection'
and `collation_connection' system variables.
The `_CHARSET_NAME' expression is formally called an _introducer_. It
tells the parser, `the string that is about to follow uses character set
X.' Because this has confused people in the past, we emphasize that an
introducer does not cause any conversion; it is strictly a signal that
does not change the string's value. An introducer is also legal before
standard hex literal and numeric hex literal notation (`x'LITERAL'' and
`0xNNNN'), and before `?' (parameter substitution when using prepared
statements within a programming language interface).
Examples:
SELECT _latin1 x'AABBCC';
SELECT _latin1 0xAABBCC;
SELECT _latin1 ?;
MySQL determines a literal's character set and collation in the
following manner:
* If both _X and `COLLATE Y' were specified, then character set X
and collation Y are used.
* If _X is specified but `COLLATE' is not specified, then character
set X and its default collation are used.
* Otherwise, the character set and collation given by the
`character_set_connection' and `collation_connection' system
variables are used.
Examples:
* A string with `latin1' character set and `latin1_german1_ci'
collation:
SELECT _latin1'Mu"ller' COLLATE latin1_german1_ci;
* A string with `latin1' character set and its default collation
(that is, `latin1_swedish_ci'):
SELECT _latin1'Mu"ller';
* A string with the connection default character set and collation:
SELECT 'Mu"ller';
Character set introducers and the `COLLATE' clause are implemented
according to standard SQL specifications.
Info Catalog
(mysql.info) charset-column
(mysql.info) charset-syntax
(mysql.info) charset-national
automatically generated byinfo2html