Skip to content

Defining Charset and Collation in table specification not supported #4168

@timsehn

Description

@timsehn

I'm following the example here:

https://dev.mysql.com/doc/refman/8.0/en/charset-collation-effect.html

First, defining charset and collation in the table specification is not echoed in show create table:

MySQL [charsets_collations]> CREATE TABLE german1 (
    ->          c CHAR(10)
    ->        ) CHARACTER SET latin1 COLLATE latin1_german1_ci;
Query OK, 0 rows affected (0.002 sec)

MySQL [charsets_collations]> show create table german1
    -> ;
+---------+----------------------------------------------------------------------------------------------------------+
| Table   | Create Table                                                                                             |
+---------+----------------------------------------------------------------------------------------------------------+
| german1 | CREATE TABLE `german1` (
  `c` char(10)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin |
+---------+----------------------------------------------------------------------------------------------------------+
1 row in set (0.001 sec)

It's not set either as you can see from the full example:

MySQL [charsets_collations]> CREATE TABLE german1 (
    ->          c CHAR(10)
    ->        ) CHARACTER SET latin1 COLLATE latin1_german1_ci;
Query OK, 0 rows affected (0.002 sec)

MySQL [charsets_collations]> CREATE TABLE german2 (
    ->          c CHAR(10)
    ->        ) CHARACTER SET latin1 COLLATE latin1_german2_ci;
Query OK, 0 rows affected (0.003 sec)

MySQL [charsets_collations]> CREATE TABLE germanutf8 (
    ->          c CHAR(10)
    ->        ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Query OK, 0 rows affected (0.002 sec)

MySQL [charsets_collations]> 
MySQL [charsets_collations]> INSERT INTO german1 VALUES ('Bar'), ('Bär');                                                                                   
Query OK, 2 rows affected (0.003 sec)

MySQL [charsets_collations]> INSERT INTO german2 VALUES ('Bar'), ('Bär');
Query OK, 2 rows affected (0.005 sec)

MySQL [charsets_collations]> INSERT INTO germanutf8 VALUES ('Bar'), ('Bär');
Query OK, 2 rows affected (0.003 sec)

MySQL [charsets_collations]> SELECT * FROM german1 WHERE c = 'Bär';
+------+
| c    |
+------+
| Bär  |
+------+
1 row in set (0.001 sec)

MySQL [charsets_collations]> SELECT * FROM german2 WHERE c = 'Bär';
+------+
| c    |
+------+
| Bär  |
+------+
1 row in set (0.001 sec)

MySQL [charsets_collations]> SELECT * FROM germanutf8 WHERE c = 'Bär';
+------+
| c    |
+------+
| Bär  |
+------+
1 row in set (0.001 sec)

The expected respsone for the last query from the docs is:

mysql> SELECT * FROM germanutf8 WHERE c = 'Bär';
+------+
| c    |
+------+
| Bar  |
| Bär  |
+------+

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestsqlIssue with SQL

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions