Lists: | pgsql-general |
---|
From: | Rich Shepard <rshepard(at)appl-ecosys(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Referencing Serial Type as Foreign Key |
Date: | 2005-06-03 17:10:43 |
Message-ID: | Pine.LNX.4.62.0506031006480.21666@salmo.appl-ecosys.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Don't know why I've not come across this before, but I have now.
In a table definition I reference the primary key of another table. That
key is of datatype SERIAL. In the referencing table, do I define the column
as
col_name INTEGER REFERENCES other-table (primary_key_field),
or is the datatype SERIAL because that's what the referenced
primary_key_field is?
Thanks,
Rich
--
Dr. Richard B. Shepard, President
Applied Ecosystem Services, Inc. (TM)
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
From: | "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com> |
---|---|
To: | Rich Shepard <rshepard(at)appl-ecosys(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Referencing Serial Type as Foreign Key |
Date: | 2005-06-03 17:21:43 |
Message-ID: | 42A091A7.4050802@commandprompt.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Rich Shepard wrote:
> Don't know why I've not come across this before, but I have now.
>
> In a table definition I reference the primary key of another table. That
> key is of datatype SERIAL. In the referencing table, do I define the column
> as
>
> col_name INTEGER REFERENCES other-table (primary_key_field),
>
> or is the datatype SERIAL because that's what the referenced
> primary_key_field is?
Serial is a psuedo type to integer/big (depending on the type of
serial). What you have above should work fine.
SIncerely,
Joshua D. Drake
>
> Thanks,
>
> Rich
>
--
Your PostgreSQL solutions company - Command Prompt, Inc. 1.800.492.2240
PostgreSQL Replication, Consulting, Custom Programming, 24x7 support
Managed Services, Shared and Dedicated Hosting
Co-Authors: plPHP, plPerlNG - http://www.commandprompt.com/
From: | Rich Shepard <rshepard(at)appl-ecosys(dot)com> |
---|---|
To: | "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Referencing Serial Type as Foreign Key |
Date: | 2005-06-03 17:26:50 |
Message-ID: | Pine.LNX.4.62.0506031025340.21666@salmo.appl-ecosys.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
On Fri, 3 Jun 2005, Joshua D. Drake wrote:
> Serial is a psuedo type to integer/big (depending on the type of serial).
Josh,
That's what I thought.
> What you have above should work fine.
OK.
Many thanks,
Rich
--
Dr. Richard B. Shepard, President
Applied Ecosystem Services, Inc. (TM)
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863