Summary of MySQL's Methods of Modifying Database Fields

1. Modify the field type

alter table table name modify column field name type;
alter table table name change column field name type;
but it should be noted that if there are already values ​​in the field, you need to confirm that NewType is compatible with these value types, otherwise the database does not allow modification

2. Modify the length of the field type
alter table table name modify column field name type;
alter table table name change column field name type;
for example, if the user table name field in the
database is varchar(30),
you can use
alter table user modify column name varchar(50 ) ;
This is modified

3. Modify the field name

1. Statement: alter table student change physics physisc char(10) not null.
2. Where char(10) not null is the create_definition of your physisc field.
Note: At this time, using modify will report an error.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326918843&siteId=291194637