views:

80

answers:

1

Hi,

I have a table with a auto-incremented primary key: user_id.

For a currently theoretical reason, I might need to change a user_id to be something else than it was when originally created through auto-incrementation. This means there's a possibility that the keys will not be in incremental order anymore:

PK:
1
2
3
952  // changed key
4
5
6
7

I'm wondering whether this will cause problems, and whether MySQL reads something special to the incremental order of the keys, given that they should have come to existence in incremental order (which persists even when some rows are deleted).

Assuming there are no associated foreignkey issues, or that these are under control, is there a problem with "messing with" the order of MySQL's autoincremented keys?

Thank you.

+2  A: 

Once you change it, the auto_increment will start with the new value. I.e. if you change a user ID to 1000, the next user will show up as 1001, preserving auto_increment semantics.

OverClocked