DEFAULT NULL COMMENT ‘注释’;
– 字段名称未改变,修改字段类型、类型长度、默认值、注释
ALTER TABLE 表名 CHANGE [column] 旧字段名 新字段名 新数据类型;
alter table table1 change column1 column1 varchar(100) DEFAULT 1.2 COMMENT ‘注释’;
– 修改字段名、字段类型、类型长度、默认值、注释
alter table table1 change column1 column2 decimal(10,1) DEFAULT NULL COMMENT ‘注释’
– 正常,能修改字段名、字段类型、类型长度、默认值、注释
alter table table1 change column2 column1 decimal(10,1) DEFAULT NULL COMMENT ‘注释’
alter table table1 change column1 column2; – 报错
mysql> alter table white_user change column name nick_name varchar(50) null comment ‘昵称’; – 正确
Query OK, 0 rows affected (0.02 sec)
Records: 0 Duplicates: 0 Warnings: 0
==================================