Home > Database > Mysql Tutorial > body text

MySQL optimization - a brief introduction to data type width

黄舟
Release: 2017-03-10 09:55:40
Original
1690 people have browsed it

Integer data types in MYSQL can specify the display width

Creating a table

       CREATE TABLE tb_emp( id BIGINT(1))
Copy after login

For example, suppose you declare an INT type field YEAR INT(4 ), this statement specifies that the data in the year field generally only displays a width of 4 digits.
The display width and the value range of the data type are irrelevant. The display width only specifies the maximum number of digits that may be displayed by MYSQL. When the number of digits is less than the specified width, spaces will be filled.

If a value larger than the display width is inserted, as long as the value does not exceed the type of integer Within the value range, values ​​can still be inserted and displayed.
                                                                                 
                                                                                                                                                  , , , , , , , , , , , , , . Then MYSQL specifies the default width value for each type
Note: The display width is only used for display and cannot limit the value range and occupied space.

For example: INT(3) will occupy 4 Bytes of storage space, and the maximum allowed value will not be 999, but the maximum value allowed by the INT integer type. ​

The above is the detailed content of MySQL optimization - a brief introduction to data type width. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!