1 Adding a single column
A ALTER TABLE list name add the parameter name ( such as age) to add the content ( such as 21); "At the bottom of all columns"
b ALTER table list name add the parameter name ( such as age) to add the content ( such as Tirst); "The newly added column is at the front"
C ALTER table list name add the parameter name (for example, age ) to add to the column specified by Afier (for example) ; " The newly added column is located below the column you specified.
2 adding multiple columns
altertableList nameADDthe name of the parameter to add(such as age) content(as);the name of the parameter to add(such as name) content(such as Sulinlin);wait"At the bottom of all columns"
3 Deleting a single column
alteertable List name DROP the name of the parameter to delete ( e.g. age ) ;
4 Deleting multiple columns
ALTER table name drop the parameter name ( such as name ) to delete , and also the parameter name ( such as age ) to delete; wait
5 You can also delete edges to add
6 Adding a PRIMARY KEY constraint ( only one )
ALTER TABLE list name PRIMARY REY ( the primary KEY constraint name to be added );( is actually the name of the parameter name)
7 Adding a unique constraint ( can have multiple )
ALTER TABLE list name add unique ( the unique constraint name to add );( is actually the parameter name, such as age )
8 adding foreign KEY constraints
altertable List name ADD FOREIGN Key ( foreign key parameter ) refrences List name (name of the parameter);
9 Adding a DEFAULT constraint
Alter ABLE table name alter parameter SET default value ;
10 Deleting a DEFAULT constraint
ALTER TABLE name alter parameter DROP DEFAULT;
11 See which parameters in the list are constrained and indexed
First step SHOW INDEXES from list name;
The second step SHOW INDEXES from list name \g;
12 Deleting a PRIMARY KEY constraint
ALTER table name DROP primapy KEY;
13 Deleting a UNIQUE constraint
ALTER table name DROP INDEX parameter;
14 Deleting a FOREIGN KEY constraint
ALTER table name DROP FOREIGN key foreign KEY constraint name;
15 Viewing FOREIGN KEY constraint names
SHOW CREATE table table name;
16 Deleting an index
ALTER TABCE table name DROP Index has an indexed parameter name;
MySQL Data modification