Bug #46239 | mysql doesn't show what collation was used if that collation is the default | ||
---|---|---|---|
Submitted: | 16 Jul 2009 19:06 | Modified: | 19 Mar 2018 17:56 |
Reporter: | Shane Bester (Platinum Quality Contributor) | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: DDL | Severity: | S4 (Feature request) |
Version: | 5.0.82, 5.1.37 | OS: | Any |
Assigned to: | Assigned Account | CPU Architecture: | Any |
[16 Jul 2009 19:06]
Shane Bester
[16 Jul 2009 19:21]
Valeriy Kravchuk
Thank you for the bug report. Verified just as described with recent bzr threes: mysql> select version(); +-----------+ | version() | +-----------+ | 5.0.85 | +-----------+ 1 row in set (0.00 sec) mysql> drop table if exists t1,t2; Query OK, 0 rows affected, 2 warnings (0.00 sec) mysql> create table t1(a char(1) charset utf8 collate utf8_general_ci) -> charset=latin1; Query OK, 0 rows affected (0.00 sec) mysql> create table t2(a char(1) charset utf8 collate utf8_bin) -> charset=latin1; Query OK, 0 rows affected (0.01 sec) mysql> show create table t1; +-------+----------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+----------------------------------------------------------------------------------------------------------+ | t1 | CREATE TABLE `t1` ( `a` char(1) character set utf8 default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 | +-------+----------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> show create table t2; +-------+---------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+---------------------------------------------------------------------------------------------------------------------------+ | t2 | CREATE TABLE `t2` ( `a` char(1) character set utf8 collate utf8_bin default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 | +-------+---------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
[16 Jul 2009 21:07]
Peter Laursen
huh .. I thought it was a *feature*! no collation displayed => default collation was defined. 9 months since I first noticed this!
[21 Jul 2009 5:10]
Alexander Barkov
This is an intentional behaviour, to reduce "SHOW CREATE TABLE" output size. However, having a full "CREATE TABLE" could be useful in some cases. Reasonable feature request.
[21 Jul 2009 5:11]
Alexander Barkov
One more comment: it works this way since version 4.1.0 when we introduced collations in MySQL. There's no regression here.
[9 Dec 2009 7:35]
MySQL Verification Team
Bar, reducing the output size of SHOW CREATE TABLE is not a useful argument here. What we need is accurate information!
[15 Dec 2009 7:35]
Alexander Barkov
Shane, I agree full information is better for reading dumps or seeing at "SHOW CREATE TABLE" output. So this is a reasonable feature request. However, from dumping and restoring point of view it's safe anyway. Even if mysql was compiled for example "--default-character-set=utf8 --default-collation=utf8_unicode_ci" it only means that when you do "CREATE DATABASE", you get "CHARACTER SET utf8 COLLATE utf8_unicode_ci" by default. The default collation for utf8 is STILL utf8_general_ci. So there's no any ambiguity depending on compilation flags here. If the future we'll probably allow to change the default collation for a character set. So full information will be important someday!
[7 Nov 2017 6:39]
MySQL Verification Team
this bug comes to light now that 8.0 has different default collation for utf8mb4 See: https://bugs.mysql.com/bug.php?id=88373
[9 Jan 2018 20:44]
Sven Sandberg
Workaround: SELECT TABLE_COLLATION FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = name; SELECT COLLATION_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = name;
[19 Mar 2018 17:56]
Paul DuBois
Posted by developer: Fixed in 8.0.11. Previously, SHOW CREATE TABLE did not show collation for a column if the collation was the same as the table default, even if the collation was explicitly specified at table-creation time. Now, SHOW CREATE TABLE always shows the column collation if the collation was explicitly specified, even if the collation is the same as the table default.
[12 Apr 2018 5:39]
Erlend Dahl
Bug#89606 PLEASE PRINT DEFAULT COLLATION IN DUMP/PUMP/SHOW CREATE TABLE Bug#89241 Modify SHOW CREATE TABLE to provide full charset and collation were marked as duplicates.
[4 Mar 5:05]
MySQL Verification Team
see https://bugs.mysql.com/bug.php?id=114195