当前位置:   article > 正文

删除 索引 外键 mysql_MySQL无法删除外键约束所需的索引(MySQL Cannot drop index needed in a foreign key constraint)...

cannot drop index fk leave word book id': needed in a foreign key constraint

MySQL无法删除外键约束所需的索引(MySQL Cannot drop index needed in a foreign key constraint)

我需要ALTER我现有的数据库来添加一列。 因此,我还要更新UNIQUE字段以包含该新列。 我试图删除当前的索引,但是不断得到错误MySQL Cannot drop index needed in a foreign key constraint

CREATE TABLE mytable_a (

ID TINYINT NOT NULL AUTO_INCREMENT PRIMARY KEY,

Name VARCHAR(255) NOT NULL,

UNIQUE(Name)

) ENGINE=InnoDB;

CREATE TABLE mytable_b (

ID TINYINT NOT NULL AUTO_INCREMENT PRIMARY KEY,

Name VARCHAR(255) NOT NULL,

UNIQUE(Name)

) ENGINE=InnoDB;

CREATE TABLE mytable_c (

ID TINYINT NOT NULL AUTO_INCREMENT PRIMARY KEY,

Name VARCHAR(255) NOT NULL,

UNIQUE(Name)

) ENGINE=InnoDB;

CREATE TABLE `mytable` (

`ID` int(11) NOT NULL AUTO_INCREMENT,

`AID` tinyint(5) NOT NULL,

`BID` tinyint(5) NOT NULL,

`CID` tinyint(5) NOT NULL,

PRIMARY KEY (`ID`),

UNIQUE KEY `AID` (`AID`,`BID`,`CID`),

KEY `BID` (`BID`),

KEY `CID` (`CID`),

CONSTRAINT `mytable_ibfk_1` FOREIGN KEY (`AID`) REFERENCES `mytable_a` (`ID`) ON DELETE CASCADE,

CONSTRAINT `mytable_ibfk_2` FOREIGN KEY (`BID&#

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/560058
推荐阅读
相关标签
  

闽ICP备14008679号