方法一:(不推荐)

 

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

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

 

posted on 2020-08-13 17:34  大话人生  阅读(395)  评论(0)    收藏  举报