本文介绍了MySQL-如何将自动增量设置为从零开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只希望我的mysql表ID(主键)从0开始..
I just want my mysql table id(primary key) to start from 0..
正如我所看到的,我使用ALTER TABLE yourtable AUTO_INCREMENT = 0,但是它从1开始.我需要做什么?
As I have seen, I used ALTER TABLE yourtable AUTO_INCREMENT =0 but it starts from 1..What is that I need to do?
Edit1
我也用truncate选项清空了表
I also emptied my table with truncate option
推荐答案
SET [GLOBAL|SESSION] sql_mode='NO_AUTO_VALUE_ON_ZERO'
如果在表的AUTO_INCREMENT列中存储了0,则此模式很有用. (顺便说一句,建议不要存储0.)
This mode can be useful if 0 has been stored in a table's AUTO_INCREMENT column. (Storing 0 is not a recommended practice, by the way.)
这篇关于MySQL-如何将自动增量设置为从零开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!