The difference is the range of values they accept (according to the table), i.e.:
Signed
SMALLINT: -32768
to 32767
INT: -2147483648
to 2147483647
Unsigned
SMALLINT: 0
to 65535
INT: 0
to 4294967295
Signed to Unsigned Difference
Each type has its limit in bytes (e.g.: SMALLINT 1 byte).
Signed: "divides" the possible amount between negative and positive.
Unsigned: "does not divide", thus accepting only positive numbers.
Value in parentheses
A very explanatory quote (Source):
5 - Values need to be filled with left zeros or have
an expected width?
The answer to the fifth question is only used for formatting
number. If we want the numbers to be returned with zeros to
left, we use the modifier "ZEROFILL". Already the "width" of
fields is used so the application can display the value with spaces to
left. The width of the fields is returned between the metadata
coming from a consultation.
The width is specified differently for integers and reals. In
integers, the width is specified in parentheses, after the
field name (for example "INT(11)"). For real numbers, a
width is precisely the precision of the field (cited above),
difference is that the accuracy number becomes the total width of the
field, including with the score.
The biggest confusion I see around is the use of the "width" of the field
finding it to be the "maximum digit capacity" of the field. That’s
wrong. That is, if the field is INT(1), INT(2) or INT(11), its value
maximum will continue to be "2.147.483.647". To specify fields with
greater or lesser capacity, field variations shall be used
(TINYINT, SMALLINT, MEDIUMINT or BIGINT for INT fields or use FLOAT
or DOUBLE for floating point fields).
Note: The ZEROFILL option automatically applies the UNSIGNED option
in the field, even if you have explicitly specified SIGNED.
Concluding your question:
You can use the SMALLINT
at the BIGINT
because everyone accepts the values: 72
, or 240
, or 300
.
The value in parentheses (3)
, means that your column will be bounded by 3 visible digits, but the values will still be possible according to field boundaries.
Useful links
Official documentation
72,240
is a broken number, so you can’t use any kind ofint
.– Roberto de Campos
@Robertodecampos is a comma to separate values, in vdd are integer values.
– Leonardo Bonetti
@Robertodecampos corrected
– Leonardo Bonetti
This raised me a beautiful question. I will ask!
– rbz