Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Foreign Key Problem

Re: Foreign Key Problem

From: Michael Serbanescu <mserban_at_postoffice.worldnet.att.net>
Date: 1998/02/20
Message-ID: <6clcjn$mav@bgtnsc02.worldnet.att.net>#1/1

As the error message tells you, a FOREIGN KEY constraint must reference either the PRIMARY KEY or any UNIQUE column or set of columns in the parent/referenced table. If you can create a UNIQUE constraint strictly on (T2Cod1, T2Cod3) in Table2, your problem is solved.

Hope this helps.

Michael Serbanescu



DINFA - Microcentro wrote:
>
> Hi
> I have two tables created as follow.
>
> Table1 Columns T1Cod1 varchar2(3) NOT NULL Primary Key
> T1Cod2 varchar2(3) NOT NULL
> T1Cod3 varchar2(3) NOT NULL
>
> Table2 Columns T2Cod1 varchar2(3) NOT NULL Primary Key
> T2Cod2 varchar2(3) NOT NULL Primary Key
>
> T2Cod3 varchar2(3) NOT NULL Primary Key
>
> I'd like to create a relationship between two tables as follow
>
> ALTER TABLE Table1 CONSTRAINT XPTO_FK
> FOREIGN KEY (T1Cod2,T1Cod3)
> REFERENCES Table2 (T2Cod1,T2Cod3)
>
> i.e. only the Columns T2Cod1 and T2Cod3 From Table2 are the Key
> Components of Foreign Key.
> When i try this an error occurs
> ORA-02270: No matching unique or Primary Key for this Column List.
>
> Is there any way to do that.
>
> Thanks in Advence
> Joe
Received on Fri Feb 20 1998 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US