From a relational database theory point of view, there should be absolutely no problem on updating the primary key of a table, provided that there are no duplicates among the primary keys and that you do not try to put a null value in any of the primary key columns.. Updating a primary key isn't a problem; all values in sql (and in the relational model) are supposed to be updatable. the problem seems to be swapping primary keys, which . doesn't make sense to me if you use surrogate keys (because they're meaningless, so updates aren't necessary) and which. To change the primary key in the table in the database, the updatecommand of the dataadapter needs to locate the row based on the original primary key and update the primary key value with the current value of the primary key in addition to updating the other row values with their current values. in the sample, this is done using the following.
Sql home sql intro sql syntax sql select sql select distinct sql where sql and, or, not sql order by sql insert into sql null values sql update sql delete sql select top sql min and max sql count, avg, sum sql like sql wildcards sql in sql between sql aliases sql joins sql inner join sql left join sql right join sql full join sql self join sql. Best practice - update primary keys. up vote 1 down vote favorite. what's you opinion about update a primary key in sql? i have a "link" table with 3 key from 3 other tables. should the administration let people to edit one of the keys? i usely said no, dont change pk. add a new line and if you want remove the other line.. Sql> update dept1 set deptno=deptno+1 ; sql> update emp1 set deptno=deptno+1 ; and it allows me to directly update without using set constraints clause. could you give an example where we use set constraint clause. update primary key story the thing is someone can mess the combination of the composite key up by selecting (not typing.