大家好,又见面了,我是你们的朋友全栈君。
原因一:
添加的外键列与另一个表的唯一索引列(一般是主键)的数据类型不同 原因二: 要添加外键的表类型与另一个表的存储引擎是不是都为innodb引擎 #查看表引擎 法一: show create table 表名; 法二:show table status from 数据库 where name=‘表名’; 法三:use information_schema; select table_catalog,table_schema,table_name,engine from tables where table_schema=‘数据库名’ and table_name=‘表名’; 原因三: 设置的外键与另一个表中的唯一索引列(一般是主键)中的值不匹配 #解决办法:删除要成为外键的列,再次创建并默认为NULL
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/147869.html原文链接:https://javaforall.cn