Unanswered: Alter table causing issues on creating FK to the existing table
I am on version 9.7.2 of db2 on LUW. I am trying to create a Foreign Key on already exisiting table to the primary key of a newly created table. The already existing table was altered to add a new column with the same definition as the primary key of the new table.
I am getting this error when I try to create the FK relationship
SQL0667N The FOREIGN KEY "CTE_FK01" cannot be created because the table
contains rows with foreign key values that cannot be found in the parent key
of the parent table. SQLSTATE=23520
Initially the Primary key was defaulted to BLANK, but I removed that option.
Please advice. The developers need it from me as urgent and I have been working on this for a while now. I cant think of anything else
The child table has data in it because it is an old table, but the new table or the parent table doesn't have any data in it yet. Also the new column(to be defined FK to the PK column of the new table) in the child table has been defined as default '' (BLANK) similar to the primary key column in the parent table. I am wondering if there is any workaround fro this kind of situation. Please let me know