Core code:
Copy codeThe Code is as follows: alter table name AUTO_INCREMENT = Set Value
ALTER [IGNORE] TABLE tbl_name alter_spec [, alter_spec...] in MySQL ALTER syntax
Copy codeThe Code is as follows: alter_specification:
ADD [COLUMN] create_definition [FIRST | AFTER column_name]
Or add index [index_name] (index_col_name ,...)
Or add primary key (index_col_name ,...)
Or add unique [index_name] (index_col_name ,...)
Or ALTER [COLUMN] col_name {set default literal | drop default}
Or CHANGE [COLUMN] old_col_name create_definition
Or MODIFY [COLUMN] create_definition
Or DROP [COLUMN] col_name
Or DROP PRIMARY KEY
Or drop index index_name
Or RENAME [AS] new_tbl_name
Or table_options
Eg:
Mysql> alter table topics change hotico hot_count int (4 );
Mysql> alter table topics alter hot_count set default 1;
Supplement:
Add Index
Mysql> alter table name add index name (field name 1 [, field name 2…]);
Example: mysql> alter table employee add index emp_name (name );
Index with primary keywords
Mysql> alter table name add primary key (field name );
Example: mysql> alter table employee add primary key (id );
Add an index with unique conditions
Mysql> alter table name add unique index name (field name );
Example: mysql> alter table employee add unique emp_name2 (cardnumber );
MySQL ALTER syntax usage: view the index of a table
Mysql> show index from table name;
Example: mysql> show index from employee;
Delete An index
Mysql> alter table Name drop index name;
Example: mysql> alter table employee drop index emp_name;
Modify TABLE: ADD a field: mysql> alter table table_name ADD field_name field_type;
View the table: mysql> SELECT * FROM table_name;
Modify the original field name and type: mysql> alter table table_name CHANGE old_field_name new_field_name field_type;
Delete field: MySQL alter table table_name DROP field_name;