我正在使用命令来更改 id 字段的自动增量序列开始的数字:
ALTER SEQUENCE orders_order_id_seq RESTART 14028;
我想将此增量增加 4 而不是 1。这可能吗?
我知道这是一个非常简短的问题,但我没有可以为此提供的代码示例。我在文档或其他问题中没有找到解决此查询的任何内容。
最佳答案
是的,这是可能的。 尝试一下
alter sequence orders_order_id_seq INCREMENT 4
PostgreSQL Documentation. ALTER SEQUENCE
increment The clause INCREMENT BY increment is optional. A positive value will make an ascending sequence, a negative one a descending sequence. If unspecified, the old increment value will be maintained.
关于postgresql - 如何在 postgres 中自动递增序列增量 4 而不是 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58179138/