mysql添加check约束,如何在MySQL表上添加自定义CHECK约束?

I am having trouble with this table

CREATE TABLE `Participants` (

`meetid` int(11) NOT NULL,

`pid` varchar(15) NOT NULL,

`status` char(1) DEFAULT NULL,

PRIMARY KEY (`meetid`,`pid`),

CONSTRAINT `participants_ibfk_1` FOREIGN KEY (`meetid`) REFERENCES `Meetings` (`meetid`) ON DELETE CASCADE

CONSTRAINT `participants_ibfk_2` CHECK (status IN ('a','d','u'))

CONSTRAINT `participants_ibfk_3` CHECK (pid IN (SELECT name FROM Rooms) OR pid IN (SELECT userid FROM People))

);

I want to have a foreign key constraint, and that works. Then, I also want to add a constraint to the attribute status so it can only take the values 'a', 'd' and 'u'. It is not possible for me to set the field as Enu

你可能感兴趣的:(mysql添加check约束)