我有一個表結構如下:mysql的刪除約束
CREATE TABLE `Lm_help` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`section` int(10) NOT NULL,
`language` int(10) NOT NULL,
`title` varchar(255) NOT NULL,
`text` text NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `unique_help` (`section`,`language`),
KEY `language_constraint` (`language`),
CONSTRAINT `language_constraint` FOREIGN KEY (`language`) REFERENCES `Lm_languages` (`id`),
CONSTRAINT `section_constraint` FOREIGN KEY (`section`) REFERENCES `Lm_help_sections` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
我需要刪除「unique_help」鍵,但我正在逐漸外鍵約束的錯誤。
由於出現此錯誤,我無法刪除其中的任何內容, section_constraint,language_constraint,unique_help。
下面是有關本其它表:
CREATE TABLE `Lm_languages` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`code` varchar(255) NOT NULL,
`status` int(11) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1
CREATE TABLE `Lm_help_sections` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1
你得到什麼錯誤到底是什麼? – 2013-05-14 11:37:59
unique_help不是主鍵,它是唯一索引。你遇到了什麼錯誤? – 2013-05-14 11:38:41
無法刪除索引'language_constraint':在外鍵約束中需要 – viv 2013-05-14 11:38:52