MySQL Forums
Forum List  »  InnoDB

Problem with "false" increment in InnoDB using a table with UNIQUE constraint
Posted by: Jefferson Felix
Date: April 30, 2011 12:15AM

Consider the following table Innodb:

CREATE TABLE `user` (
   `id` INT NOT NULL AUTO_INCREMENT,
   `name` VARCHAR (150) NOT NULL,
   `email` VARCHAR (50) NOT NULL,
   PRIMARY KEY (`id`),
   UNIQUE INDEX `email_UNIQUE` (`email` ASC))
ENGINE = InnoDB;

Consider the following attempts to insert:

INSERT INTO `user` (`name`, `email`) VALUES ('John', 'john@test.com');
INSERT INTO `user` (`name`, `email`) VALUES ('Joe', 'john@test.com');
INSERT INTO `user` (`name`, `email`) VALUES ('Mark', 'mark@test.com');

Obviously, the second instruction will not be inserted into database.
However, the result of
SELECT * FROM `user`;
is:

+----+-----------------------+
| id | name | email          |
+----+-----------------------+
| 1  | John | john@test.com  |
| 3  | Joe  | mark@test.com |
+----+-----------------------+

The question is: Why id "jumps" from 1 to 3? Is it a bug? A false increment? How to solve it?

Thanks,
Jefferson dos Santos Felix



Edited 1 time(s). Last edit at 04/30/2011 12:19AM by Jefferson Felix.

Options: ReplyQuote


Subject
Views
Written By
Posted
Problem with "false" increment in InnoDB using a table with UNIQUE constraint
2311
April 30, 2011 12:15AM


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.