Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Error enabling FK constraint
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? TypeReceived on Wed Sep 20 2000 - 11:57:53 CDT
------------------------------ -------- ----
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
![]() |
![]() |