[thelist] auto-increment with mysql

rudy rudy937 at rogers.com
Thu Jul 17 19:01:23 CDT 2003


> I didn't find this answer on the MySQL site ...

whoa, that's a shocker

> When the auto-increment column gets to it's max (let's say
> smallint(5) unsigned), does it start back at 1 again or does it just
> conk out?

it conks out gloriously

i've seen many people hit this problem when they use a tinyint as the
auto_increment and then wonder why they get an error after the 127th
row is inserted

however, i should point out that the number you have in brackets -- 
smallint(5) -- has absolutely no bearing on how many digits a smallint can
hold

smallints in mysql (and any other database that supports them -- smallint is
a standard datatype) can hold numbers between -32768 to 32767 (unsigned, a
mysql extension, 0 to 65535)

now, by coincidence, you said smallint(5), but if you had said smallint(4),
it would still hold the same range of numbers, and not conk out until you
actually hit the 32767 (or 65535) limit

this trips a lot of people up, another thing for which mysql is to blame


rudy



More information about the thelist mailing list