Alter a sequence increment
When you alter the sequence increment, the system flushes the cache.
The following example shows altering the sequence increment from 1
to 2, and the resulting next value.
dev.schema(admin)=> CREATE SEQUENCE s;
CREATE SEQUENCE
dev.schema(admin)=> SELECT NEXT VALUE FOR s;
NEXTVAL
---------
1
(1 row)
dev.schema(admin)=> ALTER SEQUENCE s INCREMENT BY 2;
ALTER SEQUENCE
dev.schema(admin)=> SELECT NEXT VALUE FOR s;
NEXTVAL
---------
100002
(1 row)
In the first NEXT VALUE call, the system gave the host a cache load of sequences 1 - 100,000. On the ALTER SEQUENCE statement, the system flushed the cache. On the second next value call, the new increment of 2 is added to the last value allocated (100,000), so the system returned the value of 100,002.