Something about the MySQL int tinyint type

Source: Internet
Author: User

After the 1.MySQL field specifies the type, the storage is fixed-length, and the Int (1) and int (4) are the same from their own lengths or stored methods. In MySQL, the difference between int (1) and int (4) is the length of the display, but to set a parameter: If the column has a zerofill, it will be displayed with 0 padding, such as 2 int (3), which will be displayed as 002.

2.int storage accounts for 4 bytes, tinyint storage accounts for 1 bytes, and the storage length determines the range of numbers they represent. The range of numbers represented by int is: integer data (all numbers) from -2^31 (-2,147,483,648) to 2^31–1 (2,147,483,647). The range represented by tinyint is a number between 0-255.

3.tinyint (1), and tinyint (3) No difference, save 123 can be saved, and if tinyint (3) Zerofill, insert value 12, will be stored 012,zerofill auto left 0, this is the limit display length.

I understand the limit display length as tinyint (1) 123 should have only one of the numbers.

Here is a concise summary:

tinyint (1) and tinyint (3) are no different, taking up bytes is a single, storage range is the same.

tinyint (3) Zerofill, when the data inserted less than 3 bits, the left automatically 0, this is the limit display length AH.

Int (1) and tinyint (1), if sufficient, preference is given to tinyint (1), since the footprint is small and space-saving.

tinyint a byte smallint two bytes mediumint three bytes int 4 bytes BIGINT 8 bytes.

However, varchar (5) Here the 5 limit is the number of characters stored, the characters are not divided into Chinese, English, digital ... )。

Summary data from the network ...

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.