troubleshooting Question

Cant create foreign key?

Avatar of futureDBA
futureDBA asked on
Oracle Database
3 Comments1 Solution1032 ViewsLast Modified:
i am trying to create a foreign key i am being given error

SQL Error: ORA-02298: cannot validate (ARIEL.MDFTICK_FK1) - parent keys not found
02298. 00000 - "cannot validate (%s.%s) - parent keys not found"
*Cause:    an alter table validating constraint failed because the table has
           child records.
*Action:   Obvious

i am using "alter table MDFTICK add constraint MDTICK_FK foreign key (THD_CUSTNO) REFERENCES MDFRPT("Custnum");//"


table 1
CREATE TABLE "ARIEL"."MDFRPT"
  (
    "Custnum"          NUMBER(6,0) NOT NULL ENABLE,
    "CM_CUSTMR_NAME"   CHAR(90 BYTE) NOT NULL ENABLE,
    "CM_CUSTMR_ADDR_1" CHAR(90 BYTE) NOT NULL ENABLE,
    "PHONE"            CHAR(39 BYTE),
    "CM_CONTACT"       CHAR(60 BYTE) NOT NULL ENABLE,
    "CM_CHNID"         CHAR(9 BYTE) NOT NULL ENABLE,
    "30"               NUMBER,
    "Current Period"   NUMBER,
    "CP With Ticket"   NUMBER,
    "Second Period"    NUMBER,
    "Third Period"     NUMBER,
    "Fourth Period"    NUMBER,
    "Total Balance"    NUMBER(11,2) NOT NULL ENABLE,
    CONSTRAINT "MDFRPT_PK" PRIMARY KEY ("Custnum") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "SALES_ARIELS" ENABLE
  )
  SEGMENT CREATION IMMEDIATE PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE
  (
    INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT
  )
  TABLESPACE "SALES_ARIELS" ;

table2
CREATE TABLE "ARIEL"."MDFTICK"
  (
    "THD_CUSTNO" NUMBER(6,0) NOT NULL ENABLE,
    "THD_TICKNO" NUMBER(10,0) NOT NULL ENABLE,
    "TH_DATE" DATE,
    "TH_PRODNO"      NUMBER(8,0) NOT NULL ENABLE,
    "TH_CRDFLG"      NUMBER(2,0) NOT NULL ENABLE,
    "TH_PRICE"       NUMBER(9,5) NOT NULL ENABLE,
    "TH_COST"        NUMBER(9,5) NOT NULL ENABLE,
    "TH_DOLRS"       NUMBER(11,2) NOT NULL ENABLE,
    "TH_UNITS"       NUMBER(9,2) NOT NULL ENABLE,
    "TH_KEYED_PRICE" NUMBER(1,0) NOT NULL ENABLE,
    CONSTRAINT "MDFTICK_PK" PRIMARY KEY ("THD_CUSTNO", "THD_TICKNO", "TH_DATE", "TH_PRODNO", "TH_CRDFLG") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "SALES_ARIELS" ENABLE
  )
  SEGMENT CREATION IMMEDIATE PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE
  (
    INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT
  )
  TABLESPACE "SALES_ARIELS" ;
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros