How do you reset MySql Auto Increment columns to 0

Hello,

Can someone help me with the MySql command to reset auto incrementing columns in a database?
cgray1223Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hernst42Commented:
ALTER TABLE tbl AUTO_INCREMENT = 100;

See http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html
k_murli_krishnaCommented:
To start with an AUTO_INCREMENT value other than 1, you can set that value with CREATE TABLE or ALTER TABLE, like this:

CREATE TABLE animals (
     id MEDIUMINT NOT NULL AUTO_INCREMENT,
     name CHAR(30) NOT NULL,
     PRIMARY KEY (id)
) ENGINE=MyISAM;

mysql> ALTER TABLE tbl AUTO_INCREMENT = 100;

When all records are deleted to reset auto increment column to start from 0
Use either
alter table <table_name> auto_increment = 0;
Or
truncate table <table_name>

There are 3 good scenarios in this rererence:
http://www.dbuggr.com/milly/reset-auto-increment-mysql/
DileepanCommented:
Are you trying to reset the column value from 0 OR 1, after deleting all records? if yes,

ALTER TABLE tbl AUTO_INCREMENT = 1;

Alternative to DELETE, a TRUNCATE TABLE command delete rows and reset the Auto increment to zero.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
theGhost_k8Database ConsultantCommented:
DELETE will not reset auto-increment. It's only TRUNCATE!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.