Thread: Create Foriegn Key

Create Foriegn Key

From
"David Busby"
Date:
List,
    How can I create a Foriegn Key after my table is created?  I cannot find
in docs (or google) anywhere.

David Busby
Systems Engineer
busby@pnts.com


Re: Create Foriegn Key

From
Mark Wilson
Date:
On Wednesday, June 4, 2003, at 06:59 PM, David Busby wrote:

> List,
>     How can I create a Foriegn Key after my table is created?  I
> cannot find
> in docs (or google) anywhere.
>
> [snip]

See Section 2.6.3 (Adding a Constraint) of the users manual included in
the 7.3.2 docs.


Re: Create Foriegn Key

From
"Ing. Roberto Andrade Fonseca"
Date:
Hi:
On Wed, 4 Jun 2003, David Busby wrote:

> List,
>     How can I create a Foriegn Key after my table is created?  I cannot find
> in docs (or google) anywhere.
Something likke this must work for you:

ALTER TABLE documento_mensaje_foro
       ADD  FOREIGN KEY (id_mensaje)
                             REFERENCES mensaje_foro ;
--
Saludos,

Roberto Andrade Fonseca
randrade@abl.com.mx


Re: Create Foriegn Key

From
Stephan Szabo
Date:
On Wed, 4 Jun 2003, David Busby wrote:

> List,
>     How can I create a Foriegn Key after my table is created?  I cannot find
> in docs (or google) anywhere.

See ALTER TABLE ADD CONSTRAINT, generally something of the form:

ALTER TABLE tablename ADD CONSTRAINT constraint name FOREIGN KEY(fkcol1)
 REFERENCES pktable(pkcol1);



Re: Create Foriegn Key

From
Jeff Fitzmyers
Date:
ALTER TABLE "foreign_table_name" ADD CONSTRAINT "fkey_name" FOREIGN KEY 
("fkey_column") REFERENCES "primary_table_name"("primary_key_column_name
") ON UPDATE CASCADE ON DELETE CASCADE

(I think :-)

http://www.commandprompt.com/ppbook/index.lxp?lxpwrap=r22871%2ehtm
http://www.commandprompt.com/ppbook/index.lxp?lxpwrap=x13546.htm

Have fun, Jeff

> List,
>     How can I create a Foriegn Key after my table is created?  I
> cannot find
> in docs (or google) anywhere.