Home >Database >Mysql Tutorial >How to modify field type in mysql
In mysql, you can use the "ALTER TABLE table name MODIFY [COLUMN] field name data type type length default value comment;" statement to modify the field type. This statement can not only modify the field type, but also modify the type length, default value, and comments.
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
Modify the type and use sql statement:
alter table 表名 alter column 字段名称 varchar not null
Example:
Create a new table as shown below:
Change the name column to varchar, with a length of 20, as shown below:
After the change, the result is:
Related Learning recommendation: mysql tutorial(video)
The above is the detailed content of How to modify field type in mysql. For more information, please follow other related articles on the PHP Chinese website!