在MySQL中对表创建的char、varchar列选择长度时,当使用例如varchar(20)时,在5.0.3版本后表示20个字符。当使用例如varchar(0)时,在MySQL官方参考手册中是这样写的:

MySQL permits you to create a column of type CHAR(0). This is useful primarily when you must be compliant with old applications that depend on the existence of a column but that do not actually use its value. CHAR(0) is also quite nice when you need a column that can take only two values: A column that is defined as CHAR(0) NULL occupies only one bit and can take only the values NULL and '' (the empty string).

大致意思是长度为零的char或varchar表示该列用来兼容旧应用(无须更改业务代码),可以为NULL或者''只需1bit存储。

相关文章:

  • 2022-02-24
  • 2022-12-23
  • 2022-12-23
  • 2022-02-15
  • 2022-12-23
  • 2021-08-01
  • 2021-07-08
  • 2021-04-04
猜你喜欢
  • 2022-01-18
  • 2021-11-22
  • 2021-07-22
  • 2021-10-26
  • 2022-01-15
  • 2021-07-26
  • 2022-02-09
相关资源
相似解决方案