Thread: SERIAL FIELD SEQUENCE MAXIMUM VALUE

SERIAL FIELD SEQUENCE MAXIMUM VALUE

From
JORGE MALDONADO
Date:
I have several tables with serial and bigserial field types. I ran pgAdmin III and checked the sequences values and I see that all of them have the same maximum; serial and bigserial maximum value is 9223372036854775807.
Why do serial and bigserial fields take the same maximum values?
Isn't it supposed that serial maximum value should be 2147483647?
 
Respectfully,
Jorge Maldonado

Re: SERIAL FIELD SEQUENCE MAXIMUM VALUE

From
Eric McKeeth
Date:
On Sat, Feb 27, 2010 at 4:43 PM, JORGE MALDONADO <jorgemal1960@gmail.com> wrote:
I have several tables with serial and bigserial field types. I ran pgAdmin III and checked the sequences values and I see that all of them have the same maximum; serial and bigserial maximum value is 9223372036854775807.
Why do serial and bigserial fields take the same maximum values?
Isn't it supposed that serial maximum value should be 2147483647?
 
Respectfully,
Jorge Maldonado

You're confusing the serial/bigserial columns with the sequences that populate them. Serial and bigserial are just shortcuts to create an integer/bigint and a sequence to use as it's default value. The sequence is just like a sequence created separately, and has no knowledge of what sort of column it's values will be inserted into, so it can return the full range of values that any sequence can return. The serial or bigserial columns however, will still only be able to store the maximum values for an int or a bigint respectively, so if you ever do insert enough records into a serial column, the sequence could return a value that results in an overflow error.

Hope that helps to answer your question.

Eric McKeeth