Re: Re: Why the ERROR: duplicate key violates unique constraint "master_pkey" is raised? - Is this a Bug?

Поиск
Список
Период
Сортировка
От Alban Hertroys
Тема Re: Re: Why the ERROR: duplicate key violates unique constraint "master_pkey" is raised? - Is this a Bug?
Дата
Msg-id 46FCBBB1.1090503@magproductions.nl
обсуждение исходный текст
Ответ на Re: Why the ERROR: duplicate key violates unique constraint "master_pkey" is raised? - Is this a Bug?  (Nis Jørgensen <nis@superlativ.dk>)
Ответы Re: Why the ERROR: duplicate key violates unique constraint "master_pkey" is raised? - Is this a Bug?  (Nis Jørgensen <nis@superlativ.dk>)
Список pgsql-general
Nis Jørgensen wrote:
> If you can't wait, you are probably better off working around the
> problem. Standard solution is to do:
>
> UPDATE  master SET m2 = -m2;
> UPDATE  master SET m2 = -m2+1;
>
> or something similar.

Would something like

UPDATE master set m2 = master2.m2
  FROM (
    SELECT m2 +1
      FROM master m
     WHERE m.master_id = master.master_id
     ORDER BY m2 DESC
 ) master2

work? I think it might be faster (and possibly cause less index bloat)
than doing two consequent updates.

Haven't tested this though...

--
Alban Hertroys
alban@magproductions.nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
   7500 AK Enschede

// Integrate Your World //


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

Предыдущее
От: Richard Huxton
Дата:
Сообщение: Re: question about pg_dump -a
Следующее
От: Nis Jørgensen
Дата:
Сообщение: Re: Normalized Tables & SELECT [was: Find "smallest common year"]