gpt4 book ai didi

MySQL 从表中删除所有行并将 ID 重置为零

转载 作者:IT老高 更新时间:2023-10-28 12:49:00 27 4
gpt4 key购买 nike

我需要从表中删除所有行,但是当我添加新行时,我希望具有自动增量的主键 ID 分别从 0 和 1 重新开始。

最佳答案

不要删除,使用截断:

Truncate table XXX

The table handler does not remember the last used AUTO_INCREMENT value, but starts counting from the beginning. This is true even for MyISAM and InnoDB, which normally do not reuse sequence values.

Source .

关于MySQL 从表中删除所有行并将 ID 重置为零,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12651867/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com