问题
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
回答1:
Take a look at this interesting article
https://wikis.oracle.com/display/mysql/Triggers#Triggers-EmulatingCheckConstraints
I often use that method.
回答2:
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
来源:https://stackoverflow.com/questions/5807231/mysql-check-constraint-alternative