From: | Richard Broersma <richard(dot)broersma(at)gmail(dot)com> |
---|---|
To: | Yan Cheng Cheok <yccheok(at)yahoo(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Is there any different for foreign key to be serial instead of integer |
Date: | 2010-01-07 04:08:54 |
Message-ID: | 396486431001062008w36addb21u4cf65b98e6d968ff@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, Jan 6, 2010 at 7:51 PM, Yan Cheng Cheok <yccheok(at)yahoo(dot)com> wrote:
> instead of let customer_id being type as integer, can i let it be serial? is there any difference?
>
> if the table referenced by customer_id is having primary key typed big serial, customer_id shall be declared as bigint ?
This is a good section about the distinction between:
serial -> integer
bigserial -> bigint
the short answer is that the serial type is actually is the datatype
*integer* with the sequence generator attached to the default value of
the column.
So it only makes sense for primary key to be defined as serial. A
serial foreign key would be nonsensical since foreign keys should be
be generating their own values.
--
Regards,
Richard Broersma Jr.
Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2010-01-07 04:23:31 | Re: FULL JOIN is only supported with merge-joinable join conditions |
Previous Message | Scott Marlowe | 2010-01-07 04:07:45 | Re: Is there any different for foreign key to be serial instead of integer |