Sequences not affected by transactions?

It would not be a good idea to rollback sequences. Imagine two transactions happening at the same time, each of which uses the sequence for a unique id. If the second transaction commits and the first transaction rolls back, then the second inserted a row with “2” while the first rolls the sequence back to “1”.

If that sequence is then used again, the value of the sequence will become “2” which could lead to a unique constraint problem.

Leave a Comment