The alter ADD command is used to increase the table's fields.
Alter ADD command format: ALTER TABLE name add field type other;
For example, a field passtest is added to table MyClass, the type is int (4), and the default value is 0:
Mysql> ALTER TABLE MyClass add passtest int (4) default ' 0 ';
1) Gazzo Primer
Mysql> ALTER TABLE name add index index name (field name 1[, field Name 2 ...]);
Example: mysql> ALTER TABLE employee ADD index emp_name (name);
2) Index of the plus primary keyword
Mysql> ALTER TABLE name add primary key (field name);
Example: mysql> ALTER TABLE employee ADD primary key (ID);
3) Index with unique restriction conditions
Mysql> ALTER TABLE name add unique index name (field name);
Example: mysql> ALTER TABLE employee add unique emp_name2 (cardnumber);
4) Delete an index
mysql> ALTER TABLE name DROP INDEX name;
Example: Mysql>alter table employee DROP index emp_name;
5) Add Field
mysql> ALTER TABLE table_name ADD field_name Field_type;
6) Modify the original field name and type
mysql> ALTER TABLE table_name change old_field_name new_field_name field_type;
7) Delete field
MySQL ALTER TABLE table_name DROP field_name;
MySQL command alter add: Add a table field