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




Sat, 25 Aug 2001 15:37:50 -0700
Peter Harvey <pharvey@codebydesign.com>
FOREIGN KEY after CREATE TABLE?
On Sunday, 26. August 2001 00:37, Peter Harvey wrote:
> How can i add foreign keys after the CREATE TABLE? Is there some
> combination of other SQL commands that will do the trick?

Peter,

try ALTER TABLE a_table ADD CONSTRAINT ... FOREIGN KEY ...

Regards,
-- 
Christof Glaser

Sun, 26 Aug 2001 01:36:58 +0200
Christof Glaser <scivi@web.de>
Re: FOREIGN KEY after CREATE TABLE?
> > How can i add foreign keys after the CREATE TABLE? Is there some
> > combination of other SQL commands that will do the trick?
>
> Peter,
>
> try ALTER TABLE a_table ADD CONSTRAINT ... FOREIGN KEY ...
>

<Grr> I hate asking stupid questions. I scanned the ALTER TABLE syntax
and somehow overlooked it.

Thanks!

Peter



Sat, 25 Aug 2001 16:59:37 -0700
Peter Harvey <pharvey@codebydesign.com>
Re: FOREIGN KEY after CREATE TABLE?