0

我正在尝试更新在另一个表中作为外键引用的字段。

mysql> 更新维护集合约='95096916-OLD' where contract='95096916';

错误 1451 (23000):无法删除或更新父行:外键约束失败 ( systems_doc. Equipment, CONSTRAINT Equipment_ibfk_1FOREIGN KEY ( contract) REFERENCES Maintenance ( contract) ON UPDATE CASCADE)

| Maintenance | CREATE TABLE `Maintenance` (
  `contract` char(30) NOT NULL,
  `quote` char(30) NOT NULL,
  `vendor` char(20) NOT NULL,
  `provider` char(20) NOT NULL,
  `product` char(30) NOT NULL,
  `expiryDate` date NOT NULL,
  `annualCost` int(11) NOT NULL,
  `reference` char(13) NOT NULL,
  `purchaseOrder` char(13) NOT NULL,
  `cq` char(10) NOT NULL,
  `cqRenewal` char(10) NOT NULL,
  `comments` char(40) NOT NULL,
  UNIQUE KEY `contract` (`contract`,`expiryDate`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 | 

| Equipment | CREATE TABLE `Equipment` (
  `vendor` char(20) NOT NULL,
  `model` char(30) NOT NULL,
  `serialNumber` char(20) NOT NULL,
  `purchaseOrder` char(20) NOT NULL,
  `purchaseDate` date NOT NULL,
  `contract` char(15) NOT NULL,
  `annualCost` int(11) NOT NULL,
  `comments1` varchar(256) DEFAULT NULL,
  `comments2` varchar(256) NOT NULL,
  PRIMARY KEY (`serialNumber`),
  KEY `contract` (`contract`),
  CONSTRAINT `Equipment_ibfk_1` FOREIGN KEY (`contract`) REFERENCES `Maintenance` (`contract`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1 | 

为什么它不级联更新?我不认为它是圆形的。谢谢你的帮助。我读过其他类似的问题,但要么我误解了它应该如何工作,要么我的设置有误。

4

0 回答 0