Please give me some advice on the length of Mysql field INT type, thank you!

WBOY
Release: 2023-03-02 09:40:01
Original
1293 people have browsed it

Example: tinyint(1)

Note: What I understand is that the maximum positive number of the Tinyint type is 255. What I don’t understand is the purpose of setting 1 here. In fact, even if the length is set to 1, numbers larger than 1 digit can still be stored.

Doubt: If there is no need to pad with zeros, does this length limit still make sense? Or is it still necessary to set it up?

Reply content:

Example: tinyint(1)

Note: What I understand is that the maximum positive number of the Tinyint type is 255. What I don’t understand is the purpose of setting 1 here. In fact, even if the length is set to 1, numbers larger than 1 digit can still be stored.

Doubt: If there is no need to pad with zeros, does this length limit still make sense? Or is it still necessary to set it up?

MySQL specifies width for integer types, such as int(11), which is meaningless for most applications: it does not limit the legal range of values, but only specifies some interactive tools for MySQL (such as the MySQL command line client) Used to display the number of characters. For storage and calculation purposes, INT(1) and int(20) are the same.

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!