Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL CHECK constraint alternative

As per the MySQL manual "The CHECK clause is parsed but ignored by all storage engines." So I know the simple solution is out of the question but is there another feasible means of coming to the same outcome? Maybe through some use of triggers or stored procedures? If so how?

Also since it is just "parsed" is that as good as saying avoid using it since it doesn't serve a purpose?

Using MySQL 5.5.11 and InnoDB tables

like image 940
swisscheese Avatar asked Apr 27 '11 16:04

swisscheese


2 Answers

Take a look at this interesting article

https://wikis.oracle.com/display/mysql/Triggers#Triggers-EmulatingCheckConstraints

I often use that method.

like image 113
Nicola Cossu Avatar answered Oct 03 '22 05:10

Nicola Cossu


I am using version 5.5.21 you can use ENUM for check constraints http://dev.mysql.com/doc/refman/5.0/en/enum.html

like image 37
umeshn Avatar answered Oct 03 '22 06:10

umeshn