MYSQL错误-写入或更新时重复密钥 [英] MYSQL Error - Duplicate key on write or update

查看:120
本文介绍了MYSQL错误-写入或更新时重复密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CREATE TABLE IF NOT EXISTS `demare`.`shop` (
    `shop_id` INT NOT NULL AUTO_INCREMENT,
    `shop_image` VARCHAR(255) NOT NULL,
    `shop_price` FLOAT(6,2) NOT NULL,
    `cart_id` INT NOT NULL,
PRIMARY KEY (`shop_id`),
INDEX `cart_id_idx` (`cart_id` ASC),
CONSTRAINT `cart_id`
  FOREIGN KEY (`cart_id`)
  REFERENCES `demare`.`shopping cart` (`cart_id`)
  ON DELETE CASCADE
  ON UPDATE NO ACTION)
ENGINE = InnoDB;

我有一个错误。无法创建我的 shop表,因为出现错误:

I have an error. My 'shop' table cannot be created as I have error:


121写入或更新时出现重复键。

121 Duplicate key on write or update.

我已经提供了代码。谁能告诉我问题出在哪里?

I have provided the codes. Can anyone tell me what the problem is?

推荐答案

问题存在,因为foriegn键存在于内存中,如果可能的话,删除数据库并重新开始。

Problem exist because the foriegn key exist in memory, if possible drop the database and start again.

这篇关于MYSQL错误-写入或更新时重复密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆