Updating MySQL primary key
I have a table user_interactions with 4 columns: user_1 user_2 type timestamp The primary key is (user_1,user_2,type) and I want to change to (user_2,user_1,type) So what I did was : drop primary key ... add primary key (user_2,user_1,type)... and voila... The problem is that database is live on a server. So before I could update the primary key, many duplicates already crept in, and they are continuously creeping in. What to do? What I want to do now is to remove duplicates and keep the ones with the latest timestamp (which is a column in the table). And then somehow update the primary key