0

I have an empty "new_table" and "old_1" + "old_2" tables. When I insert 3000 rows from old_1 to new_table everything is fine.

But when I insert data from old_2 table, auto_increment id's starts from ~4000, not from 3000.. Any ideas why this is happening? I would like to have the new rows starting from 3001.

INSERT INTO new_table ( col1,col2,col3 ) SELECT col1,col2,col3 FROM old_1;
INSERT INTO new_table ( col1,col2,col3 ) SELECT col1,col2,col3 FROM old_2;

EDIT: I havent deleted any rows or messed with auto_increment values at all. I just ran 2 queries in a row

Hese
  • 291
  • 5
  • 18
  • Possible duplicate of [MySQL: Reorder/Reset auto increment primary key?](http://stackoverflow.com/questions/740358/mysql-reorder-reset-auto-increment-primary-key) – Peter Dec 29 '15 at 12:24
  • Thank you Peter for reply, but that doesnt explain why the auto increment number skips and how to insert the new rows without skipping =/ – Hese Dec 29 '15 at 12:26
  • True, but there are other posts about that as well: http://stackoverflow.com/questions/17668369/why-does-mysql-skip-some-auto-increment-ids – Peter Dec 29 '15 at 12:29
  • check your auto_increment_offset value after inserting first table data if it is showing like 4000 then alter table with auto_increment value as 3001 and then insert other table data. – Zafar Malik Dec 29 '15 at 12:33
  • What is the DDL for the table where you insert? – Richard St-Cyr Dec 29 '15 at 14:22

0 Answers0