patternsqlModerate
Postgresql behavior at end of sequence
Viewed 0 times
postgresqlbehaviorsequenceend
Problem
As per subject when a sequence hits its max val what happens?
What is the behavior? I have a big table with a sequence as a primary key and would like to know.
Thanks.
What is the behavior? I have a big table with a sequence as a primary key and would like to know.
Thanks.
Solution
If you try it, you'll get:
This is the case when the sequence is created automatically for a
ERROR: nextval: reached maximum value of sequence "testseq" (9223372036854775807): select nextval('testseq')This is the case when the sequence is created automatically for a
serial or bigserial column. You can create a sequence with specifying CYCLE, in which case it will restart from the MINVALUE specified (or left at the default 1).Code Snippets
ERROR: nextval: reached maximum value of sequence "testseq" (9223372036854775807): select nextval('testseq')Context
StackExchange Database Administrators Q#54899, answer score: 10
Revisions (0)
No revisions yet.