MYSQL Error - Duplicate key on write or update

两盒软妹~` 提交于 2019-12-11 05:58:39

问题


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;

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

121 Duplicate key on write or update.

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


回答1:


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



来源:https://stackoverflow.com/questions/48436191/mysql-error-duplicate-key-on-write-or-update

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!