1

How can my InnoDB table increment 5 instead 1 in each entry ID?

Thanks

ID - TITLE
5  - Entry 1
10 - Entry 2
15 - Entra 3
Luciano Nascimento
  • 2,600
  • 2
  • 44
  • 80
  • then don't make **ID** column `auto_increment`. and set the value while you insert. – xkeshav Oct 29 '12 at 04:36
  • u might have deleted some old value ..due to possible relations of id with other tables .mysql dosent reorder the id on delete of any row. – Arun Killu Oct 29 '12 at 04:41
  • [See here for reference](http://stackoverflow.com/questions/3313229/mysql-auto-increment-by-5) – thar45 Oct 29 '12 at 04:43

2 Answers2

1

How about using a TRIGGER on the table? Something similar to this code:

DELIMITER $$

CREATE TRIGGER ai_increaseByFive AFTER INSERT ON tbl
  FOR EACH ROW BEGIN
    UPDATE tbl SET id = (id - 1) + 5 WHERE title = NEW.title;
  END;
$$

DELIMITER ;
GregD
  • 2,797
  • 3
  • 28
  • 39
-1

source http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html You should be able to set the amount to increment with an equals sign.

mysql> ALTER TABLE tbl AUTO_INCREMENT = 100;
JacksonReed
  • 108
  • 1
  • 7
  • This does not do what OP asked. See older answer to this question: http://stackoverflow.com/questions/1686327/change-the-step-auto-increment-fields-increment-by – mvp Oct 29 '12 at 04:33