Jump to content

Reset Product ID


frii

Recommended Posts

Hello, I have been searching for a while but haven't found the answer

 

Is there any way to reset the product ID? I have insert and deleted many products and I just realized that the deleted product's id is not being re-occupied, for example I have #1 to #14 ID then I delete #10 and #11, when I add new product it becomes #15, not taking the #10 spot

 

Is there any way to re generate the IDs so the vacant IDs can be used? because at this rate the ID will be only piled up

Edited by frii (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...
  • 1 year later...

It's not possible to set up MySQL to always use vacant IDs. You can reset the AUTO_INCREMENT value, but then it will increment to the next ID even if it's already taken. I suppose you could set the AUTO_INCREMENT to 15, then after adding a product, change it to the next vacant ID, but that's a lot of work.

  • Like 1
Link to comment
Share on other sites

Hi there,

 

as Rocky said it is not possible to tell MySQL to use old IDs. Either you truncate the table and start again from the beginning (but I don't think this is a viable solution, specially if you are working on a live site) or you keep the authomatic IDs. By the way, what's your concern about "big numbers" for IDs?

 

Best,

Federica

Link to comment
Share on other sites

You can use a query like the following to change the AUTO_INCREMENT value, but you should only set it to the next ID after the current highest ID, otherwise you'll get a "Duplicate row" error when adding a new product with an existing ID:

ALTER TABLE ps_product AUTO_INCREMENT = 1

Change ps_ to your database prefix and 1 to the ID you want to be next.

Link to comment
Share on other sites

Hi there,

 

as Rocky said it is not possible to tell MySQL to use old IDs. Either you truncate the table and start again from the beginning (but I don't think this is a viable solution, specially if you are working on a live site) or you keep the authomatic IDs. By the way, what's your concern about "big numbers" for IDs?

 

Best,

Federica

if every day import 3000+ products, in 365 days (1 year...) the "big numbers" will be over the million... 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...