MySQL database design best practices for INTEGER types and integer Best Practices

Source: Internet
Author: User

MySQL database design best practices for INTEGER types and integer Best Practices
List of storage space and value ranges occupied by various INTEGER MySQL types

Best practices

  • UNSIGNED can only store non-negative integers
  • SIGNED can store positive integers, 0, and negative integers.
  • The best practice for storing positive integers (such as primary keys) is UNSIGNED, because it occupies the same storage space as SIGNED, but the value range is doubled.
  • BOOL and BOOLEAN are just another way of writing TINYINT (1 ).
  • The storage space occupied by TINYINT (1), BOOL, and BOOLEAN is the same as that occupied by TINYINT. It is a byte instead of a bit.
  • The range of values that TINYINT (1) can store is the same as that of TINYINT. values range from-128 to 127.
  • TINYINT (1) is only output as a single bit during display.
References
  • 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 Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.