MySQL will silently truncate a larger INT than capable.
Check MySQL's own documentation here:
As we can see the maximum size of INT (which is the most commonly used) is 2147483647
A lot of coders make this mistake by using very large values such as 9999999999 but it would actually truncate to 2147483647 which is the maximum size of an INT. This is dangerous because any value over that would truncate to that exact maximum number causing duplicate or unintended entries.
Type | Storage | Minimum Value | Maximum Value |
---|---|---|---|
(Bytes) | (Signed/Unsigned) | (Signed/Unsigned) | |
TINYINT |
1 | -128 |
127 |
0 |
255 |
||
SMALLINT |
2 | -32768 |
32767 |
0 |
65535 |
||
MEDIUMINT |
3 | -8388608 |
8388607 |
0 |
16777215 |
||
INT |
4 | -2147483648 |
2147483647 |
0 |
4294967295 |
||
BIGINT |
8 | -9223372036854775808 |
9223372036854775807 |
0 |
1844674407370955161 |
mysql, maximum, int, truncation, warningmysql, silently, truncate, larger, documentation, commonly, coders, duplicate, unintended, entries, bytes, unsigned, tinyint, smallint, mediumint, bigint,