Mysql database Field modification method summary 1 Add Table field altertablestudentaddsexvarchar (2) notnull; types. modify the field type of a table and specify the field name of the specified empty or non-empty altertable name modify
Mysql database Field modification method summary 1 add table field alter table student add sex varchar (2) not null; alter table student add id int unsigned not null auto_increment primary key 2. modify the field type of a table and the field name modify, which is specified as null or not.
Summary of modifying fields in the Mysql database
1. Add Table Fields
Alter table student add sex varchar (2) not null;
Alter table student add id int unsigned not null auto_increment primary key
2. Modify the field type of a table and specify it as null or non-empty.
Alter table name modify Field Name field type [whether to allow non-null not null/null];
Eg: alter table student modify name varchar (20) null
3. Modify the field name of a table and specify it as null or not
Alter table name change field Original Name field New Name field type [whether to allow non-null not null/null]
Eg: alter table student change sex xingbie varchar (3) not null;
4. to delete a field, run the following command:
Alter table Name drop field name;
Eg: alter table student drop xingbie;