Unfortunately, MySQL does not implement a restriction CHECKor custom types. Perhaps this will change in future versions.
Until then, you can use a trigger to correct the input, if this is the way for you:
delimiter //
CREATE TRIGGER trigger_check BEFORE INSERT ON your_table
FOR EACH ROW
BEGIN
IF NEW.NUM > 99999 THEN
SET NEW.NUM = 0;
END IF;
END
//
source
share