I am trying to drop a foreign key, and I know I have to drop its constraint before, but I keep geting this error:
#1064 - You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near
'CONSTRAINT `fk_facility`' at line 2
First I did this :
ALTER TABLE `facilities`
DROP CONSTRAINT `fk_facility`;
And I aimed to do this secondly:
ALTER TABLE `facilities`
DROP FOREIGN KEY `building_Id`;
Show create table:
CREATE TABLE `facilities` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`building_Id` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`type` varchar(255) DEFAULT NULL,
`area` varchar(255) DEFAULT NULL,
`capacity` varchar(255) DEFAULT NULL,
`quantity` tinyint(4) DEFAULT NULL,
`internet` char(13) DEFAULT NULL,
`availability` char(3) DEFAULT NULL,
`comments` varchar(255) DEFAULT NULL,
PRIMARY KEY (`ID`),
KEY `fk_facility` (`building_Id`),
CONSTRAINT `fk_facility` FOREIGN KEY (`building_Id`) REFERENCES `buildings`
(`ID`) ON DELETE CASCADE) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=latin1