SMALLINT
Small integer type. A SMALLINT column uses 2 bytes and stores values from -32768 to 32767 (signed) or 0 to 65535 (unsigned).
Syntax
SMALLINT[(M)] [SIGNED | UNSIGNED | ZEROFILL]Description
Note:
Examples
With strict_mode set
CREATE TABLE smallints (a SMALLINT,b SMALLINT UNSIGNED,c SMALLINT ZEROFILL);INSERT INTO smallints VALUES (-10,-10,-10);
ERROR 1264 (22003): Out of range value for column 'b' at row 1
INSERT INTO smallints VALUES (-10,10,-10);
ERROR 1264 (22003): Out of range value for column 'c' at row 1
INSERT INTO smallints VALUES (-10,10,10);
INSERT INTO smallints VALUES (32768,32768,32768);
ERROR 1264 (22003): Out of range value for column 'a' at row 1
INSERT INTO smallints VALUES (32767,32768,32768);
SELECT * FROM smallints;
+-------+-------+-------+
| a | b | c |
+-------+-------+-------+
| -10 | 10 | 00010 |
| 32767 | 32768 | 32768 |
+-------+-------+-------+SIGNED and UNSIGNED
Out of Range
SMALLINT ZEROFILL
See Also
Last updated
Was this helpful?

