D
D
Dauren S2020-11-10 10:49:15
PostgreSQL
Dauren S, 2020-11-10 10:49:15

How to update sequence of id in postgresql?

I did an import into a Postgresql table including the id, now when inserting a new row the error occurs
duplicate key value violates unique constraint "nutrition_productcategory_pkey"
DETAIL: Key (id)=(1) already exists.
How to set the id to come from the last imported element?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2020-11-10
@dauren101

ALTER SEQUENCE nutrition_productcategory_seq RESTART WITH <последний id>;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question