Easy way to compute how close an auto_increment is to its maximum value?
Posted
by David M
on Stack Overflow
See other posts from Stack Overflow
or by David M
Published on 2010-05-05T17:26:39Z
Indexed on
2010/05/05
18:38 UTC
Read the original article
Hit count: 240
mysql
|auto-increment
So yesterday we had a table that has an auto_increment PK for a smallint that reached its maximum. We had to alter the table on an emergency basis, which is definitely not how we like to roll.
Is there an easy way to report on how close each auto_increment field that we use is to its maximum? The best way I can think of is to do a SHOW CREATE TABLE statement, parse out the size of the auto-incremented column, then compare that to the AUTO_INCREMENT value for the table.
On the other hand, given that the schema doesn't change very often, should I store information about the columns' maximum values and get the current AUTO_INCREMENT with SHOW TABLE STATUS?
© Stack Overflow or respective owner