MySQL 查询使日期列为 NULL?

MySQL 查询使日期列为 NULL?

To make a date column null, use ALTER TABLE and MODIFY and set the date to NULL. Following is the syntax −

alter table yourTableName modify column yourColumnName date NULL;登录后复制

mysql> create table DemoTable ( ShippingDate date NOT NULL ); Query OK, 0 rows affected (0.78 sec)登录后复制

mysql> insert into DemoTable values(null); ERROR 1048 (23000) − Column 'ShippingDate' cannot be null登录后复制

mysql> alter table DemoTable modify column ShippingDate date NULL; Query OK, 0 rows affected (1.81 sec) Records : 0 Duplicates : 0 Warnings : 0登录后复制

mysql> insert into DemoTable values(null); Query OK, 1 row affected (1.21 sec登录后复制

mysql> select *from DemoTable;登录后复制

+--------------+ | ShippingDate | +--------------+ | NULL | +--------------+ 1 row in set (0.00 sec)登录后复制