How to reset auto increment in mySql and

A

Anonymous

Guest
1) Does anyone know how I can reset the auto-increment in a primary key column.

2) Also, is it possible that if an ID has been deleted that the auto-increment re-uses it on the next insert?
I want to avoid having this (notice id 3 is missing and it continued with 4 instead of 3):
id - col1 - col 2
1 - blah - cdata
2 - blah - ddata
4 - blah - data
 
imroue said:
1) Does anyone know how I can reset the auto-increment in a primary key column.

2) Also, is it possible that if an ID has been deleted that the auto-increment re-uses it on the next insert?
I want to avoid having this (notice id 3 is missing and it continued with 4 instead of 3):
id - col1 - col 2
1 - blah - cdata
2 - blah - ddata
4 - blah - data
Yes you may do it but need rebuild toyr's table :(
Than you create table in MySQL in field you may set next:
Code:
CREATE TABLE animals (
             id MEDIUMINT NOT NULL AUTO_INCREMENT,
............
);
 
WiZARD said:
imroue said:
1) Does anyone know how I can reset the auto-increment in a primary key column.

2) Also, is it possible that if an ID has been deleted that the auto-increment re-uses it on the next insert?
I want to avoid having this (notice id 3 is missing and it continued with 4 instead of 3):
id - col1 - col 2
1 - blah - cdata
2 - blah - ddata
4 - blah - data
Yes you may do it but need rebuild toyr's table :(
Than you create table in MySQL in field you may set next:
Code:
CREATE TABLE animals (
             id MEDIUMINT NOT NULL AUTO_INCREMENT,
............
);

I have done this, but if I delete a row (for example row 3) and then I add a another row.. it will start with id 4 not 3..
I want it to start with ID 3 (because it doesn't exist anymore)
 
Back
Top