Home >Database >Mysql Tutorial >MySQL optimization - a brief introduction to data type width

MySQL optimization - a brief introduction to data type width

黄舟
黄舟Original
2017-03-10 09:55:401734browse

Integer data types in MYSQL can specify the display width

Creating a table

       CREATE TABLE tb_emp( id BIGINT(1))

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!

Statement:
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