I use int(255) in mysql as my id. Is this long enough? If I got about 1,000,000 records....Thank you.
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.
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.
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.
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.
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