I have linked tables, players
and playerRegSeason
. They are linked by a playerID
which is the primary key for players
and is in a strange non-numerical form. I want to make it so all new entries have unique auto incremented playerID
s. If I alter the column to be auto incrementing it changes all the current playerID
s, which I'd be ok with, but I lose the relationsihp to the playerRegSeason
. Is there a way to alter the playerID
column so it will automatically update in playerRegSeason
?
Usually you would be better off doing it in stages.
players
table and populate it.playerRegSeason
allow it to be NULL
initiallyplayerRegSeason
to point to the new playerID
column.playerRegSeason
to not allow nullsplayerRegSeason
EDIT: Elaboration of step 3 as requested
UPDATE playerRegSeason s
INNER JOIN players p ON s.playerID = p.playerID
SET s.NewPlayerID = p.NewPlayerID
However the exact syntax may vary depending on the version of SQL