Jump to content

Archived

This topic is now archived and is closed to further replies.

elioncho

Changing Auto-Increment Value

Recommended Posts

HI, I have a table that looks something like this:

CREATE TABLE orders(
  ID            INT(5) AUTO_INCREMENT NOT NULL,
  name        VARCHAR(40) NOT NULL,
  date        DATE NOT NULL,
PRIMARY KEY(ID,date) )

I want to change the value of ID to 1 again after certain time. What MySQL query can I use to make the field ID begin autoincrementing from number 1 again. Thanks..

Share this post


Link to post
Share on other sites
Why would you want to do that?  The auto-increment value is an intrinsic part of the database, not some field you should manipulate at will. 

Share this post


Link to post
Share on other sites
It seems you want to know the same thing as me :)
I haven't found anywhere on Google that suggests it is even possible but hopefully someone here will know!

Share this post


Link to post
Share on other sites
I've posted elsewhere on how to do this, much to my shagrin... if you want to empty out the table properly, TRUNCATE it, and MySQL will take care of the rest.

Share this post


Link to post
Share on other sites
The question is "why?"...

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.