Home » RDBMS Server » Server Administration » updating values in primary key column
updating values in primary key column [message #374272] Mon, 04 June 2001 02:17 Go to next message
Angel
Messages: 5
Registered: June 2001
Junior Member
I have two tables DEPT and EMP. DEPT_NO is a reference foreign key in EMP. I need to change the DEPT_NO value of a particular departement from 10 to 11. DEPT_NO 10 has child record in the EMP table. Is there some other better way of doing this , besides disabling the constraint temporarily and manually executing updates on the two tables separately?
Re: updating values in primary key column [message #374288 is a reply to message #374272] Mon, 04 June 2001 12:17 Go to previous message
Andrew again...
Messages: 270
Registered: July 2000
Senior Member
As you know, a PK should never be changed. You can however change the value of an FK (as long as it doesn't form part of the PK on the child table(s)). Another way is to delete add a new PK row, move the child records across to the new parent (by updating the FK(s)) and then deleting the original row.
Previous Topic: CHECK CONSTRAINT - HARD FOR ME, EASY FOR YOU
Next Topic: create view
Goto Forum:
  


Current Time: Thu Jul 04 02:35:08 CDT 2024