Re: Serial Foreign Key - Mailing list pgsql-general

From Michael Glaesemann
Subject Re: Serial Foreign Key
Date
Msg-id A58F4DE8-6076-11D9-B225-000A95C88220@myrealbox.com
Whole thread Raw
In response to Serial Foreign Key  (Jonathan Stafford <thecabinet@gmail.com>)
List pgsql-general
On Jan 7, 2005, at 14:45, Jonathan Stafford wrote:

> Suppose I have two tables:
>
> create table t1 (
>    id    serial    not null
> );
>
> create table t2 (
>    id    serial    not null,
>    t1    integer    not null,
>    foreign key (t1) references t1 (id)
> );
>
> Should the "t1 integer" actually be a bigint?  I ask because when I do
> "select * from t1_id_serial" the max_value is much larger than 2^32.
> Does this vary from system to system?

While all sequences are 64 bit integers, SERIAL is essentially INTEGER
DEFAULT nextval('foo_seq') (and creating the necessary sequence), so it
will only include 32 bit integers. If you want 64 bit integers, you can
use BIGSERIAL.

Best,

Michael Glaesemann
grzm myrealbox com


pgsql-general by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: warning: pg_query(): Query failed
Next
From: "Craig Bryden"
Date:
Subject: Books for experienced DB developer