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

How to modify field type in mysql

醉折花枝作酒筹
Release: 2023-01-05 16:09:07
Original
28603 people have browsed it

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template