Rechercher dans le manuel MySQL
10.3.5 Column Character Set and Collation
Every “character” column (that is, a column of type
CHAR
,
VARCHAR
, a
TEXT
type, or any synonym) has a
column character set and a column collation. Column definition
syntax for CREATE TABLE
and
ALTER TABLE
has optional clauses
for specifying the column character set and collation:
These clauses can also be used for
ENUM
and
SET
columns:
Examples:
MySQL chooses the column character set and collation in the following manner:
If both
CHARACTER SET
andcharset_name
COLLATE
are specified, character setcollation_name
charset_name
and collationcollation_name
are used.- (
The character set and collation are specified for the column, so they are used. The column has character set
utf8
and collationutf8_unicode_ci
.If
CHARACTER SET
is specified withoutcharset_name
COLLATE
, character setcharset_name
and its default collation are used.The character set is specified for the column, but the collation is not. The column has character set
utf8
and the default collation forutf8
, which isutf8_general_ci
. To see the default collation for each character set, use theSHOW CHARACTER SET
statement or query theINFORMATION_SCHEMA
CHARACTER_SETS
table.If
COLLATE
is specified withoutcollation_name
CHARACTER SET
, the character set associated withcollation_name
and collationcollation_name
are used.The collation is specified for the column, but the character set is not. The column has collation
utf8_polish_ci
and the character set is the one associated with the collation, which isutf8
.Otherwise (neither
CHARACTER SET
norCOLLATE
is specified), the table character set and collation are used.Neither the character set nor collation is specified for the column, so the table defaults are used. The column has character set
latin1
and collationlatin1_bin
.
The CHARACTER SET
and
COLLATE
clauses are standard SQL.
If you use ALTER TABLE
to convert
a column from one character set to another, MySQL attempts to
map the data values, but if the character sets are incompatible,
there may be data loss.
Traduction non disponible
Le manuel MySQL n'est pas encore traduit en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Document créé le 26/06/2006, dernière modification le 26/10/2018
Source du document imprimé : https://www.gaudry.be/mysql-rf-charset-column.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.