Modify mysql field attributes

1. Log in to the database & select the database & display all tables in the database

$ mysql -u root -p;
$ use database name;
$ show tables;

 
2. View the table structure

$ desc tablename;

 

3. Modify the field type and attribute information

alter table table name change field name field name field type [whether non-null is allowed];

alter table table name modify field name field type [whether non-null is allowed];

 

The difference between change & modify is:

change, you can modify the field name. If you don't want to modify the name, you need to enter the same field name.

modify, you cannot modify the field name, but only the attributes corresponding to the field.

 

$ alter table t_car_maintenance change title title VARCHAR(255) null;

 

Guess you like

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