Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the MAX number if I store int(255) in MySQL?

Tags:

int

mysql

I use int(255) in mysql as my id. Is this long enough? If I got about 1,000,000 records....Thank you.

like image 492
DNB5brims Avatar asked Aug 24 '11 06:08

DNB5brims


People also ask

How much data can you store in MySQL?

The internal representation of a MySQL table has a maximum row size limit of 65,535 bytes, even if the storage engine is capable of supporting larger rows. BLOB and TEXT columns only contribute 9 to 12 bytes toward the row size limit because their contents are stored separately from the rest of the row.

What means INT 11 in MySQL?

In MySQL integer int(11) has size is 4 bytes which equals 32 bit. Signed value is : - 2^(32-1) to 0 to 2^(32-1)-1 = -2147483648 to 0 to 2147483647. Unsigned values is : 0 to 2^32-1 = 0 to 4294967295.

What does INT 4 mean in MySQL?

For example, INT(4) specifies an INT with a display width of four digits. This optional display width may be used by applications to display integer values having a width less than the width specified for the column by left-padding them with spaces.


1 Answers

Something is probably just converting that to int(11) for you. Since you can't have 255 visible digits in an int, the maximum value will be 2147483647.

If you need more than that you can set it to be unsigned, since I'm assuming you have no negative ids and then you can have up to 4294967295.

If you are ever going to have more than 4 billion records (very unlikely if you're at 1 million right now), then you could use a bigint instead, which allows you to store numbers up to 18446744073709551615 at a cost of more storage space of course.

like image 136
Paul Avatar answered Sep 19 '22 19:09

Paul