MySQL optimization--Data type width

Source: Internet
Author: User
Reprint Please specify source: http://blog.csdn.net/l1028386804/article/details/46559861

Integer data types in MySQL can specify the display width

Create a table
CREATE TABLE tb_emp (id BIGINT (1))
The ID field has a data type of bigint (1), noting the subsequent number 1, which represents the display width specified by the data type, specifying the number of digits in the numeric value that can be displayed.
For example, suppose you declare a field of type int of year int (4), which indicates that the data in the year field generally shows only the width of a 4-digit number.
The display width and the value range of the data type are irrelevant. The display width only indicates the maximum number of digits that MySQL can display, if the number of digits is less than the specified width, and if a value greater than the display width is inserted, as long as the value does not exceed the range of values for that type of integer, the values can still be inserted and displayed.
For example, to insert a numeric value of 19999 into the year field, when using a select query, MySQL will display a full 5-digit 19999 instead of a 4-bit number
If you do not specify a display width, mysql specifies a default width value for each type
Note: The display width is for display only and cannot limit the range of values and footprint, for example: Int (3) consumes 4 bytes of storage, and the maximum allowable value is not 999, but the maximum allowed for int integer.

MySQL optimization--Data type width

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.