Anybody observed, the auto-increment fileds in a table is NOT always incremented by 1 with each row insert. But as per SQL manual it should be increased by 1.
Is this behavior Ok? Or I am doing something wrong.
Note: I do not write any value to this coulmn in my INSERT statement, this coulmn values are set by system automatically.
Values I have seen for auto-incrment field -> 1,2,3,4,8,9,10,18,19,20 etc... So in between the values incremented by more than 1.
Thanks Austin
Austin Einter wrote:
Anybody observed, the auto-increment fileds in a table is NOT always incremented by 1 with each row insert. But as per SQL manual it should be increased by 1.
Is this behavior Ok? Or I am doing something wrong.
Note: I do not write any value to this coulmn in my INSERT statement, this coulmn values are set by system automatically.
Values I have seen for auto-incrment field -> 1,2,3,4,8,9,10,18,19,20 etc... So in between the values incremented by more than 1.
I'm going to guess that some inserts failed but ended up incrementing the auto-increment value. This shouldn't be a real problem, just looks weird to you. The other scenario is that an insert happened followed by a delete, the delete doesn't reset the auto-increment value since rows can be deleted in the middle.
On Tue, Apr 19, 2011 at 8:43 PM, Austin Einter austin.einter@gmail.com wrote:
Anybody observed, the auto-increment fileds in a table is NOT always incremented by 1 with each row insert. But as per SQL manual it should be increased by 1.
Is this behavior Ok? Or I am doing something wrong.
Note: I do not write any value to this coulmn in my INSERT statement, this coulmn values are set by system automatically.
Values I have seen for auto-incrment field -> 1,2,3,4,8,9,10,18,19,20 etc... So in between the values incremented by more than 1.
Thanks Austin -- [ Drupal support list | http://lists.drupal.org/ ]
MySQL sets the default offset value of AUTO_INCREMENT to 1, but you can specify any _numeric_ value between 1 and 65535[1].
The gaps in values you are getting are most probably deleted rows, because neither there is a mechanism in MySQL to re-assign auto incremented values nor is it necessarily to begin with. Auto incrementing is all about generating *unique* values (usually primary keys) not "incremented by one" values.[2]
[1]http://dev.mysql.com/doc/refman/5.5/en/replication-options-master.html#sysva... [2]http://dev.mysql.com/doc/refman/5.5/en/example-auto-increment.html
Regards, Usamah