Reputation: 307
Thank you in advance for your help on this one.
Here's my issue:
Table A had spam accounts that I deleted. The rows were like: 1, 2556, 2559, 2565, 2595, etc.
Am trying to import Table A into the empty Table B in the same database. tables have different fields.
Table B declines the import because the insert is set to auto increment. Mysql table B does not seem to want to skip rows.
I went to Table A and updated the rows to:
1, 2, 3,4,5..., 18
Now when I try to create a user in Table A using PyphAdmin with user_id value of NULL, the id i get is 2596. Mysql still remembers the old incrementing sequence. How can I get Mysql table to auto-increment based on the previous row so the new id will be 19 ?
The mysql import file is encrypted in phpshield so I dont see what's going on and has no way to edit it. But I assume this is what is happening after I ruled out all other possibilities.
Upvotes: 0
Views: 1981
Reputation: 122042
PRIMARY KEY (id)
For example -
CREATE TABLE table1(
id INT(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
);
Set new autoincrement value -
ALTER TABLE table1 AUTO_INCREMENT = 19
;
Upvotes: 3