0
SQL查詢:MySQL的外鍵約束問題,當
CREATE TABLE IF NOT EXISTS `Rio VAMOOS Database`.`Card` (
`Card_id` INT(8) NOT NULL,
`Card_start_date` DATETIME NOT NULL,
`Card_end_date` DATETIME NOT NULL,
`State_validity` VARCHAR(8) NOT NULL,
`Official_Official_id` INT(8) NOT NULL,
PRIMARY KEY (`Card_id`),
INDEX `fk_Card_State1_idx` (`State_validity` ASC),
INDEX `fk_Card_Official1_idx` (`Official_Official_id` ASC),
CONSTRAINT `fk_Card_State1`
FOREIGN KEY (`State_validity`)
REFERENCES `Rio VAMOOS Database`.`State` (`Card_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Card_Official1`
FOREIGN KEY (`Official_Official_id`)
REFERENCES `Rio VAMOOS Database`.`Official` (`Official_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
MySQL表示:文件
我們似乎無法弄清楚爲什麼我們在導入時得到錯誤代碼,我們已經多次檢查過,但找不到問題。任何幫助將非常感激!! –
檢查外鍵是否正常,'State_validity'需要與'State'中的'Card_id'具有相同的類型。 'Official_Official_id'和'Official_id'一樣 – Sal00m