且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

尝试创建外键时在 MySQL 中出现错误 1822

更新时间:2022-02-09 21:59:10

在引用表中,必须有一个索引,其中外键列列在同一顺序的第一列 dev.mysql.com/doc/refman/5.6/en/create-table-foreign-keys.html 在您的示例中,您在更改表的配方中没有这样的键更改添加外键(版本)引用配方(版本

In the referencing table, there must be an index where the foreign key columns are listed as the first columns in the same order dev.mysql.com/doc/refman/5.6/en/create-table-foreign-keys.html in your example you have no such key in recipe for alter table Changes add foreign key(version) references Recipe(version