Oracle 5.0 Reference Manual page 792

Table of Contents

Advertisement

CREATE TABLE
[[DEFAULT] CHARACTER SET charset_name]
[COLLATE collation_name]]
ALTER TABLE
[[DEFAULT] CHARACTER SET charset_name]
[COLLATE collation_name]
Example:
CREATE TABLE t1 ( ... )
CHARACTER SET latin1 COLLATE latin1_danish_ci;
MySQL chooses the table character set and collation in the following manner:
• If both
CHARACTER SET X
• If
CHARACTER SET X
used. To see the default collation for each character set, use the
• If
COLLATE Y
collation
Y
• Otherwise, the database character set and collation are used.
The table character set and collation are used as default values for column definitions 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.
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
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
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:
• If both
CHARACTER SET X
CREATE TABLE t1
(
col1 CHAR(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci
) CHARACTER SET latin1 COLLATE latin1_bin;
Specifying Character Sets and Collations
tbl_name
(column_list)
tbl_name
and
COLLATE Y
is specified without COLLATE, character set
is specified without
are used.
and
COLLATE Y
are specified, character set
SET, the character set associated with
CHARACTER
CREATE TABLE
and
columns:
ENUM
SET
are specified, character set
772
and collation
X
and its default collation are
X
statement.
SHOW COLLATION
Y
and
ALTER TABLE
and collation
X
are used.
Y
and
has
are used.
Y

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents