Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How I can reset the start value for an id in MySQL

Status
Not open for further replies.

Ducu

Programmer
Joined
Oct 2, 2003
Messages
30
Location
RO
Hi,

This question is about MySQL. I have a field key in my table that I declare as primary key with autoincrement attribute.
After some testing work I decided to delete all records and I was expecting that the counting to start at 1. Wrong!!!
The first id value starts at the next value before cleaning the table.

How I can make the value starts at 1 ? when the table is empty after several cleaning.
 
Hi,

I found the solution reading the MySQL book.
When you delete the records one by one it doesn't restart the sequence from 1.
You need a DELETE FROM table; instruction to restart the sequence from 1.

Sorry !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top