MySQL Forums
Forum List  »  MySQL Workbench

Error 1022: Can't write; duplicate key
Posted by: Shirley Lee
Date: October 22, 2013 02:50PM

Hi:
I need some helps with the following problem. It looks like the error message is so straight forward and problem can be fixed as explained in my poeple postings on web. But I couldn't find anywhere in the script through the forward engineering on workbench that uses any duplicate field, not on blockID, nor fkMethodID. So I am confused as why the error and the message. Can someone kindlyhelp in explaining? Thanks ahead.


-- -----------------------------------------------------
-- Table `test2`.`method`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `test2`.`method` ;

CREATE TABLE IF NOT EXISTS `test2`.`method` (
`MethodID` TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
`Abbr` CHAR(1) NOT NULL,
`Desc` VARCHAR(45) NOT NULL,
PRIMARY KEY (`MethodID`),
UNIQUE INDEX `MethodID_UNIQUE` (`MethodID` ASC))
ENGINE = InnoDB;



-------------------------------




Executing SQL script in server

ERROR: Error 1022: Can't write; duplicate key in table 'building'

CREATE TABLE IF NOT EXISTS `test2`.`block` (

`blockID` TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,

`blockNum` VARCHAR(3) NOT NULL,

`fkMethodID` TINYINT UNSIGNED NOT NULL,

PRIMARY KEY (`blockID`),

UNIQUE INDEX `blockID_UNIQUE` (`blockID` ASC),

INDEX `fkMethodID_idx` (`fkMethodID` ASC),

CONSTRAINT `fkMethodID`

FOREIGN KEY (`fkMethodID`)

REFERENCES `test2`.`method` (`MethodID`)

ON DELETE NO ACTION

ON UPDATE NO ACTION)

ENGINE = InnoDB

Options: ReplyQuote


Subject
Views
Written By
Posted
Error 1022: Can't write; duplicate key
8433
October 22, 2013 02:50PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.