Lets say i have 10 tables which have Foreign Key defined that all points to one table's Primary Key.
Now i want to update the Primary key value to another value, and, i want all the 10 tables to get this new value into theirs FK-column.
Also note, that also only some of those 10 tables may have such FK-value that is updated in PK-table.
Can i do with some good script this task?
I would like to do somehow this way:
Update PkTable set
Pkcol=NewAvailableValue
CASCADE;
At the moment i am using following approach:
1. From table "user_constraints" find FK-constraints are binded to the Primary key about to be changed, find the list of those tables.
2. Query each table if it has the PK-value in their FK-columns, if has, then update the value to allowed other PK-value.
3. Update PK-table's primary key column value to new value.
4. commit.