As the title says: -What happens when the id field reaches its limit when auto-incrementing ?
Is there an overflow ? Can we program it to restart from 0 like a rotating index by deleting those indices beforehand?
CodePudding user response:
If you hit the limit for the data type of the column, you will get an error whenever you try to insert a new row:
nextval: reached maximum value of sequence "sequence_name"
You can change the sequence to restart from 0, but that won't help you, as you will end up with primary key violation errors. You can restart the sequence at a very low negative number and use up the negative numbers to delay the inevitable some more.
The inevitable is that at some point you will run out of numbers for your data type, and you will have to modify the table to use a numeric data type that allows a wider range of numbers. That change is very unpleasant and typically means a longer down time (although there are complicated ways to work around that).