增加主键:
//增加主键
alter table Student ADD PRIMARY KEY (ID);//这里的括号不能省略
//删除主键:前提是没有主键自增
if(主键自增){
alter table Student change ID ID INT ;
alter table Student drop PRIMARY KEY;
}else{
alter table Student drop PRIMARY KEY;
}
增加外键:
//增加外键(f_ID是另一个表的字段)
alter table Student ADD CONSTRINT FKName FOREIGN KEY ('f_ID') REFERENCE Student (ID)
//删除外键
alter table Student DROP FOREIGNER KEY FKName;