Home >Database >Mysql Tutorial >How to modify field name in mysql

How to modify field name in mysql

王林
王林Original
2020-10-13 14:07:2655661browse

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.

How to modify field name in mysql

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn