The utf8 character set uses a maximum of
three bytes per character. As of MySQL 5.5.3, to make this
character limit explicit (much as the limit of four bytes per
character is explicit in the utf8mb4
character set name, use the character set name
utf8mb3, which is an alias for
utf8. utf8mb3 can be
used in CHARACTER SET clauses, and
utf8mb3_
in collation_substringCOLLATE clauses, where
collation_substring is
bin, czech_ci,
danish_ci, esperanto_ci,
estonian_ci, and so forth. For example:
CREATE TABLE t (s1 CHAR(1) CHARACTER SET utf8mb3;
SELECT * FROM t WHERE s1 COLLATE utf8mb3_general_ci = 'x';
DECLARE x VARCHAR(5) CHARACTER SET utf8mb3 COLLATE utf8mb3_danish_ci;
SELECT CAST('a' AS CHAR CHARACTER SET utf8) COLLATE utf8_czech_ci;
MySQL immediately converts instances of
utf8mb3 in an alias to
utf8, so in statements such as
SHOW CREATE TABLE or SELECT
CHARACTER_SET_NAME FROM INFORMATION_SCHEMA.COLUMNS
or SELECT COLLATION_NAME FROM
INFORMATION_SCHEMA.COLUMNS, users will see the true
name, utf8 or
utf8_.
collation_substring
The utf8mb3 alias is also valid in certain
places other than CHARACTER SET clauses.
For example, these are legal:
mysqld --character-set-server=utf8mb3 SET NAMES 'utf8mb3'; /* and other SET statements that have similar effect */ SELECT _utf8mb3 'a';