Database Reference
In-Depth Information
To specify a character set and collation for a table, CREATE TABLE (seen
in Chapter 21, “Creating and Manipulating Tables”) is used with additional
clauses:
Input
CREATE TABLE mytable
(
columnn1 INT,
columnn2 VARCHAR(10)
) DEFAULT CHARACTER SET hebrew
COLLATE hebrew_general_ci;
Analysis
This statement creates a two column table, and specifies both a character set
and a collate sequence.
In this example both CHARACTER SET and COLLATE were specified, but if
only one (or neither) is specified, this is how MariaDB determines what to use:
If both CHARACTER SET and COLLATE are specified, those values are
used.
If only CHARACTER SET is specified, it is used along with the default
collation for that character set (as specified in the SHOW CHARACTER
SET results).
If neither CHARACTER SET nor COLLATE is specified, the database
default is used.
In addition to being able to specify character set and collation tablewide,
MariaDB also allows these to be set per column, as seen here:
Input
CREATE TABLE mytable
(
columnn1 INT,
columnn2 VARCHAR(10),
column3 VARCHAR(10) CHARACTER SET latin1 COLLATE latin1_general_ci
) DEFAULT CHARACTER SET hebrew
COLLATE hebrew_general_ci;
Analysis
Here CHARACTER SET and COLLATE are specified for the entire table as well
as for a specific column.
Search WWH ::




Custom Search