MySQL CHECK constraint alternative

社会主义新天地 提交于 2019-11-26 17:24:15

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!