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

How to modify field type in mysql

醉折花枝作酒筹
醉折花枝作酒筹Original
2021-04-16 11:52:2828605browse

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.

How to modify field type in mysql

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:

How to modify field type in mysql

Change the name column to varchar, with a length of 20, as shown below:

How to modify field type in mysql

After the change, the result is:

How to modify field type in mysql

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!

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