문제

There's a way to reset auto-increment field when all rows is deleted from table?

I've noticed if i have 300 rows inside my table, and i execute

DELETE * FROM myTable;

When i insert new row after delete, auto increment count continue count from last value (also if table is empty. It's possible to reset auto increment count when all rows are deleted?

도움이 되었습니까?

해결책

You need to use TRUNCATE instead of DELETE
Like this: TRUNCATE myTable;

It also much faster than DELETE (especially on big tables)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top