Should a primary key be immutable?
- by Vincent Malgrat
A recent question on stackoverflow provoked a discussion about the immutability of primary keys. I had thought that it was a kind of rule that primary keys should be immutable. If there is a chance that some day a primary key would be updated, I thought you should use a surrogate key. However it is not in the SQL standard and some RDBMS' "cascade update" feature allows a primary key to change.
So my question is: is it still a bad practice to have a primary key that may change ? What are the cons, if any, of having a mutable primary key ?