COLLATE
Clause in Various Parts of an SQL Query
COLLATE
Clause Precedence
BINARY
Operator
Every table has a table character set and a table collation, which
may not be null. The CREATE TABLE
and ALTER TABLE
statements now
have optional clauses for specifying the table character set and
collation:
CREATE TABLE table_name ( column_list ) [CHARACTER SET character_set_name [COLLATE collation_name]] ALTER TABLE table_name [CHARACTER SET character_set_name] [COLLATE collation_name]
Example:
CREATE TABLE t1 ( ... ) CHARACTER SET latin1 COLLATE latin1_danish_ci;
MySQL chooses the table character set and collation thus:
CHARACTER SET X
and COLLATE Y
were specified, then
character set X
and collation Y
.
CHARACTER SET X
was specified without COLLATE
, then
character set X
and its default collation.
The table character set and collation are used as default values, if the column character set and collation are not specified in individual column definitions. The table character set and collation are MySQL extensions; there are no such things in standard SQL.