Re: Tables referencing each other

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Felix Finch <felix(at)crowfix(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Tables referencing each other
Date: 2003-12-19 20:42:18
Message-ID: 11698.1071866538@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Felix Finch <felix(at)crowfix(dot)com> writes:
> CREATE TABLE xyzzy (a INT PRIMARY KEY, b INT REFERENCES plugh);
> CREATE TABLE plugh (c INT PRIMARY KEY, d INT REFERENCES xyzzy);

> I can't actually do this in 7.4, so I had to create the first table
> without the reference.

> Is it possible to pre-declare the second table, similar to a C
> prototype, so the first definition would not complain about the second
> table being unknown?

No. What you do is create the tables, then ALTER TABLE ADD FOREIGN KEY.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-12-19 20:45:13 Re: Salvage older PostgreSQL data disk - help?
Previous Message Tom Lane 2003-12-19 20:36:33 Re: DB & Log Files removed...