开发者

How to set value range to a column in mysql?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜