The range of tinyint

mysql> show create table gamedb.test;
+-------+------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+------------------------------------------------------------------------------------------------------------------------+
| test | CREATE TABLE `test` (
`name` varchar(255) NOT NULL,
`values` tinyint(4) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+------------------------------------------------------------------------------------------------------------------------+
1 row in set

mysql> insert into test select 'wanggong',158
-> ;
1264 - Out of range value for column 'values' at row 1

Why not write in 158?

Started by Allan at November 25, 2016 - 2:57 AM

TINYINT[(M)] [UNSIGNED] [ZEROFILL]

A very small integer. -128 127 is signed. 0 to 255 is the unsigned range.

Posted by Opera at December 04, 2016 - 3:08 AM

.

Posted by Tobias at December 15, 2016 - 3:37 AM

Type in unsigned is enough

Posted by Nigel at December 29, 2016 - 4:33 AM

smallint(4)

Posted by Regan at January 09, 2017 - 5:56 AM

The company proposes using int. After maintenance.!

Posted by Julia at January 13, 2017 - 4:56 AM