I have a table with an Autoincremental Not NULL ID ( Primary Key ) field . The issue is that I had not realized that when performing the inserts, the numbering suffers jumps, making the ID 's not consecutive.
I use Xampp with MySQL 5.0.12.
I read that setting innodb_autoinc_lock_mode
the value to 1 could achieve the desired correlative. But it does not work. I even tried all the settings:
innodb_autoinc_lock_mode = 0
("traditional"
innodb_autoinc_lock_mode = 1
lock mode) ("continuous"
innodb_autoinc_lock_mode = 2
lock mode) ("interleaved" lock mode)
Is there any way to make the autoincremental work correlatively?
What is happening to you is that the
INSERT
failed records that violate a key, eitherUNIQUE
orFK
, increase theid
even if nothing has been inserted.The first thing I would tell you is that your problem does not really exist because the number of a
id
, as long as it is unique, should give you exactly the same. If what you need is correlative labeling, you should create a field for that purpose and manage it accordingly.If the TOC gets the better of you, you can always adjust the
id
after each insert and thus get around the hassle of failed inserts with:And use that data in:
Try this configuration:
I hope it works for you.