Re: SERIAL FIELD SEQUENCE MAXIMUM VALUE - Mailing list pgsql-novice

From Eric McKeeth
Subject Re: SERIAL FIELD SEQUENCE MAXIMUM VALUE
Date
Msg-id 4bef63731002271613x1a082d52tc725c89d2365704a@mail.gmail.com
Whole thread Raw
In response to SERIAL FIELD SEQUENCE MAXIMUM VALUE  (JORGE MALDONADO <jorgemal1960@gmail.com>)
List pgsql-novice
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

pgsql-novice by date:

Previous
From: JORGE MALDONADO
Date:
Subject: SERIAL FIELD SEQUENCE MAXIMUM VALUE
Next
From: Mladen Gogala
Date:
Subject: Browsing through the Postgres source