MySQL Forums
Forum List  »  Newbie

How to force auto-increment field to increase monotonically
Posted by: Austin Einter
Date: April 19, 2011 08:53PM

Hi All
Multiple rows are inserted to a table with single INSERT IGNORE statement.
I have one auto-increment coulmn in table.

With first insert operation in auto-increment coulmn, values are set by mysql nicely.

With second insert operation, if I try to write multiple rows (and some duplicate rows are there), then the auto-increment coulmn values are jumping by some value.

So my auto-increment coulmn, looks something as below

1
2
3
4
9
10
11
18
19
20

Most probably when INSERT operation is initiated but did not succeed because of dulicate key, that time auto-increment value is jumping.

Want to know is there any mechanism in SQL, by which I can force all values in auto-incrment coulmn should be incrementing monotonically.

Thanks
Austin

Options: ReplyQuote




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.