Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL - Setting Integer Length [duplicate]

I'm using PhpMyAdmin to set my table structures.

As I'm learning to use the columns correctly, I'm curious about choosing the right integer type, and most importantly the Length (phpmyadmin requires it)

From the DZone.com I've read this:

Field Type Breakdown INT 0 to 4,294,967,295 TINYINT 0 to 255 SMALLINT 0 to 65535 MEDIUMINT 0 to 16,777,215 BIGINT 0 to 18,446,744,073,709,551,615

And that helps me decide which integer type I'm most likely to use. From the chart, I believe I need the SMALLINT, as I need more than 255.

But as I prepare it in phpmyadmin, I'm required to enter a Length/Value.

Choosing Integer Type in Phpmyadmin

If I'm sure my ID's won't get higher than 3000, do I put the number 4 in the Length/Value box?

like image 667
coffeemonitor Avatar asked Oct 11 '25 19:10

coffeemonitor


2 Answers

its called the display size. The actual length of the values are not changed in any way so an int of length 5 and an int with no length will take up the same space.

like image 181
exussum Avatar answered Oct 14 '25 13:10

exussum


the 4 will accept the values of 4 integers so it can be 4 yes. the values will be accepted till 9999

this can help you

like image 45
echo_Me Avatar answered Oct 14 '25 14:10

echo_Me