Skip site navigation (1) Skip section navigation (2)

FOREIGN KEY after CREATE TABLE?

From: Peter Harvey <pharvey(at)codebydesign(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: FOREIGN KEY after CREATE TABLE?
Date: 2001-08-25 22:37:50
Message-ID: 3B8828BE.8EF3D137@codebydesign.com (view raw or flat)
Thread:
Lists: pgsql-hackers
How can i add foreign keys after the CREATE TABLE? Is there some
combination of other SQL commands that will do the trick?

My problem is;

a. that I have a circular reference between 3 tables
b. that I must be able to reverse engineer the resulting references in
the shema by querying for foreign keys

Right now I am calculating a dependency hierarchy and generating tables
in the resulting order but this does not work for a circular ref.

Aside from the circular ref issues... i think it would be easier and
safer to be able to generate all of the tables in one pass (with primary
key defs) and then add the foreign keys in a second pass.

Any help appreciated.

Peter




Responses

pgsql-hackers by date

Next:From: Larry RosenmanDate: 2001-08-25 23:15:33
Subject: Re: [PATCHES] Makefile.PL for Pg.so
Previous:From: Bruce MomjianDate: 2001-08-25 20:15:42
Subject: Re: linking hba.c

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group