方法一:(不推荐)

 

drop table_name;     #删除表

django重新建表。

方法二:

1.查询当前自增字段的值

SELECT AUTO_INCREMENT FROM information_schema.tables WHERE table_name="car_code";

2.修改自增字段的值

ALTER TABLE car_code AUTO_INCREMENT = 471121;

 

 

ALTER TABLE table_name AUTO_INCREMENT=1;   #  重新设置id开始值为1即可

 

 

例如:

  表名:shucaiyidate_vsixxieyiduizhao

  SELECT AUTO_INCREMENT FROM information_schema.tables WHERE table_name="shucaiyidate_vsixxieyiduizhao";

  ALTER TABLE shucaiyidate_vsixxieyiduizhao AUTO_INCREMENT=1

 

方法三:

truncate tbname ;
直接清空所有数据,并将auto_increment重置为0。

例如:

  表名:shucaiyidate_vsixxieyiduizhao

  truncate shucaiyidate_vsixxieyiduizhao

重置完成后,要重启数据库才能生效

 

相关文章:

  • 2022-12-23
  • 2021-11-17
  • 2021-06-24
  • 2022-12-23
  • 2021-07-12
  • 2021-10-25
  • 2022-01-17
  • 2022-12-23
猜你喜欢
  • 2021-10-17
  • 2021-08-24
  • 2022-01-24
  • 2022-03-01
  • 2021-04-10
  • 2022-12-23
相关资源
相似解决方案