Re: Serial Foreign Key

From: Michael Glaesemann <grzm(at)myrealbox(dot)com>
To: Jonathan Stafford <thecabinet(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Serial Foreign Key
Date: 2005-01-07 06:37:48
Message-ID: A58F4DE8-6076-11D9-B225-000A95C88220@myrealbox.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2005-01-07 07:48:37 Re: functions in postgresql
Previous Message Bruno Wolff III 2005-01-07 06:25:15 Re: warning: pg_query(): Query failed