How to reset auto increment in mySql and

Codes here !

Moderators: macek, egami, gesf

User avatar
imroue
New php-forum User
New php-forum User
Posts: 62
Joined: Fri Oct 11, 2002 6:53 am
Contact:

How to reset auto increment in mySql and

Postby imroue » Thu Dec 05, 2002 7:16 am

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

User avatar
WiZARD
Moderator
Moderator
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol
Contact:

Re: How to reset auto increment in mySql and

Postby WiZARD » Thu Dec 05, 2002 8:29 am

imroue wrote: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: Select all

CREATE TABLE animals (
             id MEDIUMINT NOT NULL AUTO_INCREMENT,
............
);

User avatar
imroue
New php-forum User
New php-forum User
Posts: 62
Joined: Fri Oct 11, 2002 6:53 am
Contact:

Re: How to reset auto increment in mySql and

Postby imroue » Thu Dec 05, 2002 9:12 am

WiZARD wrote:
imroue wrote: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: Select all

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)


Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 0 guests

cron