For the third time it has happened to me that a sequence has been set to an initial value (zero or one, not sure) while in the table, there are around 1500 records. When it happens, new rows cannot be inserted from my application. So I would like to know possible causes for the sequence to be out of sync like that. Because I have no idea why this problem is occurring.
Tell me more
×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.
There are a few possible cases where things can get out of sync.
Those are your only two possibilities unless you have a short cycle, and are cycling. | |||||
|
Was your sequence created with the "CYCLE" option? You can check by querying the sequence directly
Look at the "max_value" and "is_cycled" columns. What those attributes mean is covered in more detail at http://www.postgresql.org/docs/current/static/sql-createsequence.html | |||||||||||||
|
drop sequence ..; create sequence ...;
, you are callingsetval(..)
or you usetruncate table restart identity
somewhere. Also, please show us the output ofselect version()
– a_horse_with_no_name Aug 29 at 13:48