0

I have a MySQL table table with two fields: id and name. id is primary key with auto_increment. The thing is when I insert a record and then empty the table, and insert a record again, the id value does not start from 1, it keeps increasing even though the table was emptied.
How can I make the id valued to start from 1 after emptying the table.

3
Contributors
3
Replies
4
Views
4 Years
Discussion Span
Last Post by hericles
Featured Replies
  • 1

    How do you empty the table, with a tool, or with a query? Your tool should have an option to do that, for the query: [CODE] ALTER TABLE `table` AUTO_INCREMENT = 1; [/CODE] Read More

  • TRUNCATE persons; will clear out the table and reset the auto_increment primary key to zero. Read More

1

How do you empty the table, with a tool, or with a query? Your tool should have an option to do that, for the query:

ALTER TABLE `table` AUTO_INCREMENT = 1;
1

TRUNCATE persons; will clear out the table and reset the auto_increment primary key to zero.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.