SQL Error: ORA-02298: cannot validate (SYSTEM.AEROPUERTO_FK) - parent keys not found
There are records in AEROPUERTO
that point to records that do not exist in CIUDAD
.
To find out which records of AEROPUERTO
have that kind of issue:
select * from AEROPUERTO where CODIGO_CIUDAD not in (select CODIGO from CIUDAD)
If the result set is not empty, you do have orphanaged records. You'll need to add the missing CIUDAD
records in order to create the AEROPUERTO_FK
foreign key, or update all the erroneous AEROPUERTO.CODIGO_CIUDAD
to null (if this is a nullable field, but you will lose the city information for those airport records).
Why is parent key not found?
The error message may be a bit cryptic at first, but it is pretty clear.
The only difference between the two INSERT
s is for HARDWARE_ID
. Hence 'H0002'
is not a valid HARDWARE_ID
. It is not in the HARDWARE
table.
Error Code 1452 When attempting to Alter Table Constraint
Use this to find out what entry is screwing things up
SELECT CHAR_TRIP, CHAR_DESTINATION
FROM charter
WHERE CHAR_DESTINATION NOT IN (
SELECT AIRPORT_CODE FROM airport);
ORA-02298 - Parent keys not found when enable constraint
It appears you are migrating detail records without ensuring that all the foreign key values are present in the referenced tables. If this is the case then you need to migrate records from REGION@SOURCE_DB
into REGION@TARGET_DB
before you migrate the COUNTRY
records.
Related Topics
Oracle Unique Constraint Based on Column Value
Whats The Best Sqlite Data Type for a Long String
Sqlite3 Database Is Locked in Azure
Why Doesn't Oracle Allow Consecutive Newline Characters in Commands
How to Search for Names with Apostrophe in SQL Server
Does Sqlite Support Replication
Sql Order by on Multiple Column
What Is The Meaning of Kanatype Sensitive Ks and Width Sensitive
Update X Set Y = Null Takes a Long Time
Indexed View Vs Indexes on Table
Null Value for Int in Update Statement
How to Get Rightmost 10 Places of a String in Oracle
What Is The Limit of The Field Type Bigint in Sql
Inserting a String with Double Quotes into a Table
Failed to Create an Assembly in Sql
Does SQL Server 2008 Support The Create Assertion Syntax
Why Do I Get an Open Transaction When Just Selecting from a Database View