TinyText - 255 chars
MediumText - 65535 chars
If I give
ALTER TABLE attributes MODIFY stringValue text(32766)
It doesn't not work for me. It takes only the default max text size
ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
TinyText - 255 chars
MediumText - 65535 chars
If I give
ALTER TABLE attributes MODIFY stringValue text(32766)
It doesn't not work for me. It takes only the default max text size
ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
Simple way of doing it would be to have a check constraint for field stringvalue to reject anything having length greater than 32766 but unfortunately MySQL does not support SQL check constraints. You can define them in your DDL query for compatibility reasons but they are just ignored.
There is a simple alternative
You can create BEFORE INSERT and BEFORE UPDATE triggers which either cause an error or set the field to its default value when the requirements of the data are not met.
Example for BEFORE INSERT working after MySQL 5.5
DELIMITER $$
CREATE TRIGGER `CheckLengthStringValue` BEFORE INSERT ON `attributes`
FOR EACH ROW
BEGIN
IF CHAR_LENGTH( NEW.stringValue ) > 32766 THEN
SIGNAL SQLSTATE '12345';
SET MESSAGE_TEXT := 'check constraint on Attributes.stringValue failed';
END IF;
END$$
DELIMITER ;
Prior to MySQL 5.5 you had to cause an error, e.g. call a undefined procedure.