Table Character Set and Collation : COLLATION Character Set : Table MySQL TUTORIALS


MySQL TUTORIALS » Table » COLLATION Character Set »

 

Table Character Set and Collation


Every table has a table character set and a table collation.

The CREATE TABLE and ALTER TABLE statements have optional clauses for specifying them:

CREATE TABLE tbl_name (column_list)
    [[DEFAULTCHARACTER SET charset_name] [COLLATE collation_name]]

ALTER TABLE tbl_name
    [[DEFAULTCHARACTER SET charset_name] [COLLATE collation_name]

Example:

CREATE TABLE t1 first_name varchar(30) ) CHARACTER SET latin1 COLLATE latin1_danish_ci;

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

If both CHARACTER SET X and COLLATE Y were specified, then character set X and collation Y.

If CHARACTER SET X was specified without COLLATE, then character set X and its default collation.

If COLLATE Y was specified without CHARACTER SET, then the character set associated with Y and collation Y.

Otherwise, the database character set and 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.

Quote from MySQL document: www.mysql.com




Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

MySQL TUTORIALS

 Navioo Table
» COLLATION Character Set