Re: Problem assigning a foreign key

Re: Problem assigning a foreign key

 

  

It doesn't have anything to do with the names of the tables or keys. It is
telling you that you have DATA in the child table the doesn't have matching
records in the Parent table.

You'll either:

1. Create the constraint without validation, so that Foreign Key will be in
effect going forward.
2. Add the missing records into the Parent table.
3. Delete the orphan records from the Child table.

<<MrO>>

----- Original Message -----
From: "Terance W. Ebert "
<oracledba-ezmlmshield-x56271154.[Email address protected]
To: "LazyDBA Discussion" <[Email address protected]
Sent: Tuesday, October 30, 2007 6:02 PM
Subject: RE: Problem assigning a foreign key


> [[Email Address Removed] ~]$ oerr ora 2298
> 02298, 00000,"cannot validate (%s.%s) - parent keys not found"
> // *Cause: an alter table validating constraint failed because the table
has
> // orphaned child records.
> // *Action: Obvious
>
> -----Original Message-----
> From: Dave [mailto:oracledba-ezmlmshield-x77369211.[Email address
protected]
> Sent: Tuesday, October 30, 2007 4:58 PM
> To: LazyDBA Discussion
> Subject: Problem assigning a foreign key
>
> I'm trying to set a foriegn key in a table that has the same column name
as another table where that column name in the other table has already been
set as the primary key, but I got an error:
>
> ALTER TABLE oil_customers
> ADD CONSTRAINT housetype_oil_customers_fk FOREIGN KEY(housetype)
REFERENCES oil_housetype;
>
> ERROR at line 2:
> ORA-02298: cannot validate (SCOTT.HOUSETYPE_OIL_CUSTOMERS_FK) - parent
keys not found
>
> Could this be because of the underscores? I know that the underscore that
comes right after 'housetype' is part of the code, and also the one coming
right before 'fk', but by co-incidence, I had already named the table
'oil_customers' some time ago. Is that underscore in oil_customers confusing
SQL ?
> If I rename all the tables to eliminate the underscore in their names,
wont that screw up other things?
> Thanks.
>
>
>
> ---------------------------------------------------------------------
> TO REPLY TO EVERYBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY To post a
dba job: http://jobs.lazydba.com To Subscribe : http://www.LazyDBA.com To
unsubscribe: http://www.lazydba.com/unsubscribe.html
>
>
>
>
>
> ---------------------------------------------------------------------
> TO REPLY TO EVERYBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
> To post a dba job: http://jobs.lazydba.com
> To Subscribe : http://www.LazyDBA.com
> To unsubscribe: http://www.lazydba.com/unsubscribe.html
>
>


Oracle LazyDBA home page