db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Todorovich, Milo" <Milo_Todorov...@pamperedchef.com>
Subject RE: adding foreign key that refers to primary key of same table
Date Thu, 28 Jun 2007 18:06:40 GMT
Just like any other foreign key.

This example will work:



CREATE TABLE PERSON(
	ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 1) NOT
NULL PRIMARY KEY,
	OTHER_PERSON_ID INTEGER):
	
ALTER TABLE PERSON ADD CONSTRAINT PERSON_FK1 KEY(OTHER_PERSON_ID)
REFERENCES PERSON(ID) ;
 


-----Original Message-----
From: Amir Michail [mailto:amichail@gmail.com] 
Sent: Thursday, June 28, 2007 10:57 AM
To: Derby Discussion
Subject: adding foreign key that refers to primary key of same table

Hi,

How do you add a foreign key to an existing table that refers to the
primary key of that table?

Amir

Mime
View raw message