Re: Cannot insert a duplicate key into unique index

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Cannot insert a duplicate key into unique index
Дата
Msg-id 28971.1077167439@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Cannot insert a duplicate key into unique index  (<kynn@panix.com>)
Ответы Re: Cannot insert a duplicate key into unique index  (daq <daq@ugyvitelszolgaltato.hu>)
Список pgsql-novice
<kynn@panix.com> writes:
> The insert statement that is producing this error does not
> include a value for the pkey field in question (this field is of type
> SERIAL).  I imagine that somehow the counter associated with this
> field got messed up, so that it is mistakenly generating a value that
> has been used already.  How can I straighten it out?

You need to do something like

    select setval('seq-name', (select max(col) + 1 from table));

            regards, tom lane

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

Предыдущее
От: Noel
Дата:
Сообщение: Re: Cannot insert a duplicate key into unique index
Следующее
От: daq
Дата:
Сообщение: Re: Cannot insert a duplicate key into unique index