Home > Database > Mysql Tutorial > MySQL Learning Series 2: Data Type Width/View Field Length

MySQL Learning Series 2: Data Type Width/View Field Length

黄舟
Release: 2016-12-28 17:37:00
Original
1919 people have browsed it

1. Data type width

Display width

The integer data type in MYSQL can specify the display width, but SQLSERVER cannot

MySQL Learning Series 2: Data Type Width/View Field Length

Create a table

The data type of the id field is BIGINT(1). Note the number 1 at the end, which indicates that the data type is specified. The display width specifies the number of digits in the value that can be displayed.

For example, suppose you declare a field of type INT YEAR INT(4)

This declaration indicates that the data in the year field generally only displays a width of 4 digits.

An error will be reported in SQLSERVER

##The display width has nothing to do with the value range of the data type. 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, there will be spaces filled


If a value larger than the display width is inserted, as long as the value does not exceed the integer of this type Within the value range, values ​​can still be inserted and displayed.

For example, insert a value 19999 into the year field. When using select query, MYSQL will display the complete 19999 with 5 digits instead of the 4-digit value

If the display width is not specified, MYSQL specifies a default width value for each type

tips: The display width is only used for display and cannot limit the value range and occupied space. For example: INT(3) will It occupies 4 bytes of storage space, and the maximum value allowed is not 999, but the maximum value allowed by the INT integer type

.

2. Check the field length

Check the field length


SQLSERVER

MySQL Learning Series 2: Data Type Width/View Field Length


MYSQL

MySQL Learning Series 2: Data Type Width/View Field Length

The above is the content of MySQL Learning Series 2: Data Type Width/View Field Length. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com )!



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