Von CREATE TABLE
:
Der CHECK
-Klausel wird geparst, aber ignoriert von allen Speicher-Engines.
Zweitens:
CREATE TRIGGER SexCheck BEFORE INSERT ON STUDENT
FOR EACH ROW
BEGIN
IF New.Sex NOT IN('F', 'M') THEN
SIGNAL SQLSTATE '10000'
SET MESSAGE_TEXT = 'check constraint on Student.Sex failed';
END IF;
END;
INSERT INTO STUDENT(Sex) VALUES ('B');
-- check constraint on Student.Sex failed