Add this to your PK and it will automatically update all FKs for you:
ON UPDATE CASCADE
For full details, you can read this article.
EDIT Based on your comment, if you want to change the PK data type, it depends on the change:
- If the old type can be implicitly casted to the new type without any loss:
- Change the PK type first.
- Change the FK type to the same.
- If the old type cannot be implicitly casted to the new type without any loss:
- Break the relationship first (i.e. remove the FK restriction/index).
- Convert the PK. If the data needs to be modified, save both the old values and the new ones in a temporary table.
- Convert the FK. If the PK data was changed in previous step, update the FK using the mapped values from the temporary table.
- Create the relationship again (i.e. create the FK restriction/index).
To modify the data type, use the ALTER
command, the syntax is:
ALTER TABLE table_name
ALTER COLUMN column_name datatype
Examples:
ALTER TABLE table_name
ALTER COLUMN id NUMBER(10,2);
ALTER TABLE table_name
ALTER COLUMN id VARCHAR(20);
For full details, you can read this article.