2

MySQL 1022 can't write duplicate key in table

 1 year ago
source link: https://segmentfault.com/a/1190000039682308
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

MySQL 1022 can't write duplicate key in table

发布于 今天 10:55

MySQL 1022 can't write duplicate key in table

image.png

不同数据表所设置的外键名称重复了。


例子:
myorder订单表和cart购物车表都有外键userId,关联user表中的主键userId。且二者外键名一样,则报错。
image.png

image.png

修改一下外键名称即可。(比如这里修改cart表的)

image.png

1022 can't write duplicate key in table #‘sql_XXXXX’


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK