开发者

How to set value range to a column in mysql?

开发者 https://www.devze.com 2023-03-04 20:16 出处:网络
I want to set a value range to a column of a table. Example For the decimal decimal, This decimal column should allow to insert or update the value between开发者_如何学编程 0 to 30.

I want to set a value range to a column of a table.

Example For the decimal decimal, This decimal column should allow to insert or update the value between开发者_如何学编程 0 to 30.

Thanks in advance...!


As MySQL still doesn't support check constraints, the only way to do this in MySQL is a trigger (for update and insert) that checks the new value of the column and throws an error if the value is outside the valid range.


look for ENUM and SET Constraints http://dev.mysql.com/doc/refman/5.6/en/constraint-enum.html

0

精彩评论

暂无评论...
验证码 换一张
取 消