Modify table name (RENAME)
1. Pass the ALTER keyword
ALTER TABLE tbl_name RENAME [to | As] new_name;
2. By rename keyword
RENAME TABLE tbl_name to New_name; (to not omit)
Adding a field (add)
ALTER TABLE tbl_name ADD field Name field type [integrity constraint] [first | After field name];
[First | After field name]: Specifies the location of the field
Delete field (drop)
ALTER TABLE tbl_name DROP field name
Modify field type, integrity constraint, location (MODIFY)
ALTER TABLE tbl_name MODIFY field Name field type [integrity constraint] [first | After field name];
Modify field name (change)
ALTER TABLE tbl_name change old field name new field Name field type [integrity constraint] [first| After field name];
Add defaults (SET default)
Alter TABLE tbl_name ALTER FIELD name SET default value;
Delete defaults (drop default)
Alter TABLE tbl_name ALTER FIELD name DROP default value;
Add primary Key
ALTER TABLE tbl_name ADD [CONSTRAINT [symbol]] PRIMARY key[index_type] (field name, ...);
Delete primary key
ALTER TABLE tbl_name DROP PRIMARY KEY;
Add unique
ALTER TABLE tbl_name ADD [CONSTANT [symbol]] UNIQUE [INDEX | KEY] [index name] (field name, ...);
Remove unique
ALTER TABLE tbl_name DROP {INDEX | KEY} index_name;
Modify the table's storage engine
ALTER TABLE tbl_name engine= storage engine name;
Set self-growing values
ALTER tbl_name auto_increment= value;
This article is from the "zgw285763054" blog, make sure to keep this source http://zgw285763054.blog.51cto.com/11591804/1879303
MySQL Modify table Structure command