Spec-Zone .ru
спецификации, руководства, описания, API

10.1.3.4. Column Character Set and Collation

Every "character" column (that is, a column of type CHAR, VARCHAR, or TEXT) 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:

col_name {CHAR | VARCHAR | TEXT} (col_length)    [CHARACTER SET charset_name]    [COLLATE collation_name]

These clauses can also be used for ENUM and SET columns:

col_name {ENUM | SET} (val_list)    [CHARACTER SET charset_name]    [COLLATE collation_name]

Examples:

CREATE TABLE t1(    col1 VARCHAR(5)      CHARACTER SET latin1      COLLATE latin1_german1_ci);ALTER TABLE t1 MODIFY    col1 VARCHAR(5)      CHARACTER SET latin1      COLLATE latin1_swedish_ci;

MySQL chooses the column character set and collation in the following manner:

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.