MySQL-自动递增10 [英] MySQL - Auto_increment by 10
本文介绍了MySQL-自动递增10的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何设置auto_increment列,使其对每个记录插入都增加10.
How do I set the auto_increment column in such a way that it increments by 10 for each record insert.
例如:代替默认的auto_increment
减1
For eg: Instead of the default auto_increment
by 1,
insert into temptable (name) values('abc'),('def');
select * from temptable;
id|name
1|abc
2|def
auto_increment by 10,
id|name
10|abc
20|def
推荐答案
You would have to change the auto_increment_increment
setting, however this would apply to all tables at once. I don't think there is a per-table increment setting.
但是,通常这并不是一个好主意.您是否要生成发票编号或其他内容?在这种情况下,使用生成下一个数字的自定义方法可能会更好.
This is usually not really a good idea to do, though. Are you looking to generate invoice numbers or something? In that case, you may be better off using a custom method that generates the next number.
这篇关于MySQL-自动递增10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文