Bug #6552 CHAR column w/o length is legal, BINARY w/o length is not
Description:
CHAR holds non-binary strings and BINARY holds binary
strings, but other than that, the two column types are
similar in most ways.
However, there is one inconsistency in how columns of
the two types can be declared. CHAR can be declared
without a length, and becomes CHAR(1). BINARY cannot
be declared without a length. An error occurs if you try
it.
How to repeat:
mysql> CREATE TABLE t1 (c CHAR);
Query OK, 0 rows affected (0.01 sec)
mysql> SHOW CREATE TABLE t1\G
*************************** 1. row ***************************
Table: t1
Create Table: CREATE TABLE `t1` (
`c` char(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1 row in set (0.00 sec)
mysql> CREATE TABLE t2 (b BINARY);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds
to your MySQL server version for the right syntax to use near ')' at line 1
Suggested fix:
Allow BINARY without a length to be used as a
synonym for BINARY(1).
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.046 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: CHAR holds non-binary strings and BINARY holds binary strings, but other than that, the two column types are similar in most ways. However, there is one inconsistency in how columns of the two types can be declared. CHAR can be declared without a length, and becomes CHAR(1). BINARY cannot be declared without a length. An error occurs if you try it. How to repeat: mysql> CREATE TABLE t1 (c CHAR); Query OK, 0 rows affected (0.01 sec) mysql> SHOW CREATE TABLE t1\G *************************** 1. row *************************** Table: t1 Create Table: CREATE TABLE `t1` ( `c` char(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 1 row in set (0.00 sec) mysql> CREATE TABLE t2 (b BINARY); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 Suggested fix: Allow BINARY without a length to be used as a synonym for BINARY(1).