還有一個(gè)是alter table users1 add truename varchar(20) not null first;
就是加一列到開(kāi)頭空入。
alter table users2 add unique(username);
alter table users2 add foreign key(pid)references provinces (id);
alter table users2 alter age set default 15;
alter table users2 alter age drop default;
alter table users2 drop primary key;
alter table users2 drop index usersname;
alter table users2 modify id smallint unsigned not null first;
把id放到第一列
alter table users2 modify id tinyint unsigned not null first;
把id放到第一列并且修改數(shù)據(jù)類型干签,但是從smallint到tinyint可能會(huì)造成數(shù)據(jù)丟失。
alter table users2 change pid p_id tinyint unsigned not null;
把pid改成p_id并且修改數(shù)據(jù)類型
alter table users2 rename users3;
rename table users3 to users2;
可以用show tables 來(lái)查看這個(gè)數(shù)據(jù)庫(kù)中的所有數(shù)據(jù)表