Re: Adding a Foreign Key

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: tankgirl(at)worldonline(dot)es
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Adding a Foreign Key
Date: 2001-09-03 17:31:17
Message-ID: Pine.BSF.4.21.0109031029270.76325-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Mon, 3 Sep 2001 tankgirl(at)worldonline(dot)es wrote:

> Hello everyone,
>
> I know that a Primary Key can be added to a table before it has been created, doing this...
>
> CREATE UNIQUE INDEX table_pkey ON table (atribute);
>
> Well I wonder if a Foreign Key can also be added and what syntax does it follow.

alter table <table> add <table constraint definition>

ie something like:
alter table foo add constraint foo_fk foreign key(col)
references bar(barcol) on update cascade deferrable
initially deferred;

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2001-09-03 17:33:01 Re: query not using index
Previous Message Stephan Szabo 2001-09-03 17:28:01 Re: Referential Integrity --> SystemTables