自增长跟PHP索引数组的下标一样,会根据当前最大的那个值加1。
为什么系统能够从1开始进行自动增长?而为什么每次又是自动增加1?
系统是通过系统里面的配置文件来识别。
show variables like ‘auto_increment%’;
那么我如何修改这两项呢?????
伊谢尔伦2017-04-17 13:39:47
CREATE TABLE `xxx` (
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
)AUTO_INCREMENT=4;
伊谢尔伦2017-04-17 13:39:47
It is not recommended to modify the system settings. If you need to modify the auto-increment starting value of a certain table, you can use:
alter table table_name auto_increment = 9999;
伊谢尔伦2017-04-17 13:39:47
As Ewellyuan said, it is best not to modify system properties, but only modify table properties. If you really want to change it, you can modify it through the following command:
mysql> set [global] auto_increment_increment=X;
where global refers to the global modification. Without global, it is just the session level (for the current user connection, if you exit The modification will be invalid)