Adding check constraints without "create assertion" in MYSQL

I'm trying to add a check constraint to the tables ORDERS and RESULTS in my database, but MYSQL won't accept assertions. How do I edit this to fit MYSQL's accepted syntax? Can it be done with an ALTER TABLE?

CREATE ASSERTION
CHECK (NOT EXISTS SELECT * FROM ORDERS, RESULTS, 
WHERE ORDERS.ORDER_NUMBER = RESULTS.ORDER_NUMBER 
AND ORDERS.ORDER_DATE > RESULTS.DATE_REPORTED);

Upvotes: 1

Views: 2679

Answers (1)

aweis
aweis

Reputation: 5596

MySQL does not support check constraints, so they will be ignored. look at MySQL Doc to see the allowed syntaxes. You can try using a trigger instead to check the inserted data at insert/update time!

Upvotes: 1

Related Questions