MySQL various INTEGER types occupy storage space, value range list
Best practices
- UNSIGNED can only store non-negative integers
- Signed can store positive integers, 0, negative integers
- The best practice for storing always positive integers, such as primary keys, is UNSIGNED, because it takes up as much storage space as signed, but with a value range of more than one
- BOOL, BOOLEAN is just another way to TINYINT (1).
- TINYINT (1), BOOL, and BOOLEAN occupy the same storage space as TINYINT, which is a byte, not a
- The range of values that TINYINT (1) can store is the same as TINYINT, which is 128 to 127
- TINYINT (1) Just output as a bit at the time of display
Resources
- Http://dev.mysql.com/doc/refman/5.6/en/integer-types.html
- http://stackoverflow.com/questions/4401673/mysql-boolean-tinyint1-holds-values-up-to-127
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
MySQL Database design Various INTEGER type best practices