Home  >  Article  >  Backend Development  >  Please give me some advice on the length of Mysql field INT type, thank you!

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

WBOY
WBOYOriginal
2016-12-01 01:27:171333browse

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.

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