Home >Database >Mysql Tutorial >How to modify field name in mysql
Mysql method to modify field names: execute the [ALTER TABLE table name CHANGE old field name new field name new data type;] statement to modify the field name.
mysql modify field name:
(recommended tutorial: mysql video tutorial)
ALTER TABLE 表名 CHANGE 旧字段名 新字段名 新数据类型; 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; -- 报错
Related recommendations: mysql tutorial
The above is the detailed content of How to modify field name in mysql. For more information, please follow other related articles on the PHP Chinese website!