Re: duplicate key value violates unique constraint "chinese_price_infos_pkey"

Поиск
Список
Период
Сортировка
От Michael Nolan
Тема Re: duplicate key value violates unique constraint "chinese_price_infos_pkey"
Дата
Msg-id CAOzAquJA6wjod8b70jw+2q-LZFm5DwVPUf5zuW_wstqFmj9KDA@mail.gmail.com
обсуждение исходный текст
Ответ на duplicate key value violates unique constraint"chinese_price_infos_pkey"  (Arup Rakshit <ar@zeit.io>)
Список pgsql-general


On Mon, May 6, 2019 at 6:05 AM Arup Rakshit <ar@zeit.io> wrote:

SELECT MAX(id) FROM chinese_price_infos;  max   --------  128520(1 row)
SELECT nextval('chinese_price_infos_id_seq');  nextval ---------   71164(1 row)
Not sure how it is out of sync. How can I fix this permanently. I ran vacuum analyze verbose; still same error

Vacuuming the table doesn't change the fact that your sequence isn't generating unique keys.  Without knowing the full history of the table, I can only speculate as to how keys got inserted that are beyond the sequence's current vlue, but most likely you will need to use the sequence manipulation function setval to set the sequence to at least one greater than the current maximum value. 
--
Mike Nolan

В списке pgsql-general по дате отправления:

Предыдущее
От: Ray O'Donnell
Дата:
Сообщение: Re: duplicate key value violates unique constraint"chinese_price_infos_pkey"
Следующее
От: Michel Pelletier
Дата:
Сообщение: Re: Looking for feedback and contributions