MySQL: Changing order of auto-incremented primary keys?

Posted by Tom on Stack Overflow See other posts from Stack Overflow or by Tom
Published on 2010-03-08T15:02:26Z Indexed on 2010/03/08 15:06 UTC
Read the original article Hit count: 272

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.

© Stack Overflow or respective owner

Related posts about mysql

Related posts about primary-key