MySQL Database design Various INTEGER type best practices

Source: Internet
Author: User
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.