修改表时添加和删除约束
- alter table students modify column s_name varchar(20) not null; #添加
- alter table students modify column s_name varchar(20) ; #删除
- alter table students modify column age int default 18; #添加
- alter table students modify column age;#删除
- alter table students modify column id int primary key; #添加
- alter table students modify column id int;#删除不掉的
- alter table students drop primary key;#删除
- alter table students modify column seat int unique; #添加
- alter table students drop index seat;#删除
- show index from students;#查看唯一约束
- alter table students add foreign key(major_id) references majors(id); #添加
- alter table students drop foreign key fk_students_majors;#删除