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

Home -> Community -> Mailing Lists -> Oracle-L -> Error enabling FK constraint

Error enabling FK constraint

From: Helmut Daiminger <hdaiminger_at_vivonet.com>
Date: Wed, 20 Sep 2000 09:57:53 -0700
Message-Id: <10625.117467@fatcity.com>


Hi!

I just started with a new company and was asked to have a look at our database and implement some more PK - FK constraints, since not all of them were implemented from the beginning... No comment...

Anyway, if I want to enable e.g. the following constraint

SQLWKS> alter table TB_DEPT add foreign key (STORELOCID) references tb_stores(STORELOCID);

I get the follwing error message: ORA-02270: no matching unique or primary key for this column-list

What can I do about this? The two tables look like:

TB_DEPT: Pimary Key: companyid, storelocid, deptid

SQLWKS> desc tb_dept

Column Name                    Null?    Type

------------------------------ -------- ----
COMPANYID (= PK) NOT NULL NUMBER STORELOCID (= PK) NOT NULL NUMBER DEPTID (= PK) NOT NULL NUMBER DESCRIPTION NOT NULL VARCHAR2(50) PRNPRI NOT NULL NUMBER INVTYPEID NUMBER SALESGRPID NUMBER TAXGRPID NUMBER ACCOUNTID NUMBER STATUS NOT NULL CHAR(2)

TB_STORES: Primary Key: companyid, storelocid

SQLWKS> desc tb_stores

Column Name                    Null?    Type

------------------------------ -------- ----
COMPANYID (= PK) NOT NULL NUMBER STORELOCID (= PK) NOT NULL NUMBER DESCRIPTION NOT NULL VARCHAR2(50) TIMEZONEID NOT NULL NUMBER STATUS NOT NULL CHAR(2) ENDDAY NOT NULL DATE
Received on Wed Sep 20 2000 - 11:57:53 CDT

Original text of this message

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