sql swap primary key values
问题 is it possible to swap primary key values between two datasets? If so, how would one do that? 回答1: Let's for the sake of simplicity assume you have two records id name --------- 1 john id name --------- 2 jim both from table t (but they can come from different tables) You could do UPDATE t, t as t2 SET t.id = t2.id, t2.id = t.id WHERE t.id = 1 AND t2.id = 2 Note: Updating primary keys has other side effects and maybe the preferred approach would be to leave the primary keys as they are and