Monday, 17 June 2013

Oracle: Foreign Key(Error) : ORA-02298: cannot validate (tablespace.FK_table1) - parent keys not found

                     Adding a foreign key to an existing table, some times it show the error like "ORA-02298: cannot validate (tablespace.FK_table1) - parent keys not found"

Way to solve:

Sample Query to know about the parent and child tables.,

select xxxxx from child_table a where not exists (select 'x' from
parent_table where primary_key = a.key_values);

Description.,


This will show you the row (or rows) that exists in the child table that
don't exist in the parent table. Once you have either (added rows
to the parent table to match the child rows) or (removed the child
rows that don't have parents), then you can enable your RI constraints

DBT - Models

Models are where your developers spend most of their time within a dbt environment. Models are primarily written as a select statement and ...