修改 MySQL 字段允许为空
Modify a MySQL column to allow NULL

将表中的一个字段设置允许为空的语法应该是怎样的?

What is the syntax to alter a table to allow a column to be null?

mysql

admin

https://stackoverflow.com/questions/212939/how-do-i-modify-a-mysql-column-to-allow-null

``` ALTER TABLE mytable MODIFY mycolumn VARCHAR(255) NULL; ``` 有时候,``NULL`` 部分不是必须的,但是,这样写并没有错。另外,``TIMESTAMP`` 类型是一种特殊情况,在没有给出 ``NULL`` 部分时,该字段可能默认是 ``NOT NULL``,这取决于 MySQL 的版本和配置。

``` ALTER TABLE mytable MODIFY mycolumn VARCHAR(255) NULL; ``` Whilst the NULL clause isn't required, there's nothing wrong with providing it. There's an edge case which is the ``TIMESTAMP`` type, does it be ``NOT NULL`` depends on MySQL version and config.