例如我现在的表的属性
把sex设值为varchar(6)
alter table 表名 modify column 属性 类型;
alter table student modify column sex varchar(6);
设置约束,输入性别会检查男和女
alter table 表名 add constraint 约束名(可以空) check(约束条件);
alter table `student` add constraint checksex check(`sex`='男'or `sex`='女');
之后对于输入的其他值就会报错拒绝加入。
删除约束
ALTER TABLE `student` DROP CHECK checksex;