If I want to store a port number in MySQL, what is the most efficient way (minimizing wasted space) to do so? Is it INT(5)
or INT(3)
?
I'm looking here and I think the answer is INT(3)
(or perhaps MEDIUMINT
).
Port number is an unsinged 16-bit integer. That means the highest value can be 65535. So you can use SMALLINT.
If you want to store the values as compactly as possible, the choice would be SMALLINT UNSIGNED
which takes 2 bytes of storage.
See the manual for details.
Also FYI INT(5)
and INT(3)
both use 4 bytes of storage. The (5)
and (3)
are only used for display, not for storage.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With