TINYINT
Very small integer type. A TINYINT column uses 1 byte and stores values from -128 to 127 (signed) or 0 to 255 (unsigned).
Syntax
TINYINT[(M)] [SIGNED | UNSIGNED | ZEROFILL]Description
Examples
CREATE TABLE tinyints (a TINYINT,b TINYINT UNSIGNED,c TINYINT ZEROFILL);With strict_mode set
INSERT INTO tinyints VALUES (-10,-10,-10);
ERROR 1264 (22003): Out of range value for column 'b' at row 1
INSERT INTO tinyints VALUES (-10,10,-10);
ERROR 1264 (22003): Out of range value for column 'c' at row 1
INSERT INTO tinyints VALUES (-10,10,10);
SELECT * FROM tinyints;
+------+------+------+
| a | b | c |
+------+------+------+
| -10 | 10 | 010 |
+------+------+------+
INSERT INTO tinyints VALUES (128,128,128);
ERROR 1264 (22003): Out of range value for column 'a' at row 1
INSERT INTO tinyints VALUES (127,128,128);
SELECT * FROM tinyints;
+------+------+------+
| a | b | c |
+------+------+------+
| -10 | 10 | 010 |
| 127 | 128 | 128 |
+------+------+------+SIGNED and UNSIGNED
Out of Range
TINYINT ZEROFILL
See Also
Last updated
Was this helpful?

