Create Foriegn Key

Started by David Busbyalmost 23 years ago5 messagesgeneral
Jump to latest
#1David Busby
busby@pnts.com

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

In reply to: David Busby (#1)
Re: Create Foriegn Key

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

#3Mark Wilson
mwilson13@cox.net
In reply to: David Busby (#1)
Re: Create Foriegn Key

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.

#4Jeff Fitzmyers
jeff@cloverpub.com
In reply to: David Busby (#1)
Re: Create Foriegn Key

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

Show quoted text

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

#5Stephan Szabo
sszabo@megazone23.bigpanda.com
In reply to: David Busby (#1)
Re: Create Foriegn Key

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);