sarita nelagudda
sarita nelagudda

Reputation: 25

how to auto increment with 1 after deleting data from table

i'm deleting previous data and trying to insert new list of data,id values are keep on increment because of auto-increment. is it possible to have new auto increment id with 1 ?

and i tried with ALTER TABLE table AUTO_INCREMENT = 1; its not working for me.

Upvotes: 2

Views: 2348

Answers (2)

Onkar Musale
Onkar Musale

Reputation: 909

Use this query while deleting your old 20 Records.

truncate table YourTableName;

It will reset the database structure and if you insert new record it will start from 1(one) id again.

Upvotes: 2

Dhruv
Dhruv

Reputation: 612

You cannot reset the counter to a value less than or equal to the value that is currently in use. For both InnoDB and MyISAM, if the value is less than or equal to the maximum value currently in the AUTO_INCREMENT column, the value is reset to the current maximum AUTO_INCREMENT column value plus one.

And also read this article Link

Just visit this question

Upvotes: 0

Related Questions