Обсуждение: Create Foriegn Key

Поиск
Список
Период
Сортировка

Create Foriegn Key

От
"David Busby"
Дата:
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

От
Mark Wilson
Дата:
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

От
"Ing. Roberto Andrade Fonseca"
Дата:
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

От
Stephan Szabo
Дата:
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

От
Jeff Fitzmyers
Дата:
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.