Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Now I am about to launch a site and I have trouble coming up with a way to create long user id(e.g. 4000002).

Do I set id to auto-increment(Starts at 0) and then add something(e.g. 4000000) to this id and put this new number in a new column in my table?

Does any body have a better practice to achieve this?

Thanks in advance!

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Why not just set the auto_increment to 4000000 and let it count from there?

ALTER TABLE `table` AUTO_INCREMENT=4000000;

Also, make sure your id column can fit large numbers (bigint or similar)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.