其他分享
首页 > 其他分享> > Failed to add the foreign key constraint. Missing index for constraint 'stu_ibfk_1' in the

Failed to add the foreign key constraint. Missing index for constraint 'stu_ibfk_1' in the

作者:互联网

alter table stu add foreign key(cno) references user(id);

Failed to add the foreign key constraint. Missing index for constraint 'stu_ibfk_1' in the referenced table 'user'

解决方案:

作为外键,user表中的id必须是唯一值,因此得添加约束unique,或者primary key;

标签:index,reference,constraint,foreign,stu,add,user,key
来源: https://www.cnblogs.com/ykpkris/p/15337673.html