Collations. You have two choices, not three:
utf8_bin
treats all of these as different: demandé
and demande
and Demandé
.
utf8_..._ci
(typically utf8_general_ci
or utf8_unicode_ci
) treats all of these as the same: demandé
and demande
and Demandé
.
If you want only case sensitivity (demandé
= demande
, but neither match Demandé
), you are out of luck.
If you want only accent sensitivity (demandé
= Demandé
, but neither match demande
), you are out of luck.
Declaration. The best way to do whatever you pick:
CREATE TABLE (
name VARCHAR(...) CHARACTER SET utf8 COLLATE utf8_... NOT NULL,
...
PRIMARY KEY(name)
)
Don't change collation on the fly. This won't use the index (that is, will be slow) if the collation is different in name
:
WHERE name = ... COLLATE ...
BINARY. The datatypes BINARY
, VARBINARY
and BLOB
are very much like CHAR
, VARCHAR
, and TEXT
with COLLATE ..._bin
. Perhaps the only difference is that text will be checked for valid utf8 storing in a VARCHAR ... COLLATE ..._bin
, but it will not be checked when storing into VARBINARY...
. Comparisons (WHERE
, ORDER BY
, etc) will be the same; that is, simply compare the bits, don't do case folding or accent stripping, etc.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…