MySQL Forums
Forum List  »  Newbie

Re: auto_increment not in order
Posted by: Guelphdad Lake
Date: September 17, 2010 07:49AM

a database table is not a flat file. you can't expect a particular order without an order by clause as noted. the database itself will decide where to insert a new row, it may not be inserted at the "end" of the table so don't rely on that.

also if you have deleted the row with id=3 the rest of the rows don't automatically change their id.

you should be using an auto_increment column for uniqueness only (most often when you don't have a suitable natural key for the table) and not rely on it to be in a certain order for your application code, though many people confuse that point.

---------------
Guelphdad,
Moderator
forums.mysql.com

Options: ReplyQuote


Subject
Written By
Posted
September 17, 2010 02:39AM
Re: auto_increment not in order
September 17, 2010 07:49AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.