出现这种错误 Cannot delete or update a parent row: a foreign key constraint fails 原因为:
所设置外键id的值范围超出了外键参照表i的值
alter table classadd foreign key(cid) references student(class_id);
所以,设置外键id的值范围不能超过参照表id的值
*** 一致性
两个相应的字段类型必须一致,字段长度必须一致
有值性
两个表相关联的id必须有值,
范围性
设置为外键的id值范围不能超过参照表相关联id的值<