我想将表的自动递增字段强制设置为某个值,我对此进行了尝试:
I would like to force the auto increment field of a table to some value, I tried with this:
ALTER TABLE product AUTO_INCREMENT = 1453AND
ALTER SEQUENCE product RESTART WITH 1453; ERROR: relation "your_sequence_name" does not exist我是postgres的新手:(
I'm new to postgres :(
我有一个带有Id和name字段的表product
I have a table product with Id and name field
推荐答案如果使用id列创建了表product,则该序列将不简单地称为product,而是product_id_seq(是${table}_${column}_seq).
If you created the table product with an id column, then the sequence is not simply called product, but rather product_id_seq (that is, ${table}_${column}_seq).
这是您需要的ALTER SEQUENCE命令:
ALTER SEQUENCE product_id_seq RESTART WITH 1453您可以使用psql中的\ds命令查看数据库中的序列.如果您执行\d product并查看列的默认约束,则nextval(...)调用也将指定序列名称.
You can see the sequences in your database using the \ds command in psql. If you do \d product and look at the default constraint for your column, the nextval(...) call will specify the sequence name too.
更多推荐
在postgres中重置自动增量计数器
发布评论