Re: FAQ addition: deleteing all but one unique row

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: FAQ addition: deleteing all but one unique row
Дата
Msg-id 5496.1044890736@sss.pgh.pa.us
обсуждение исходный текст
Ответ на FAQ addition: deleteing all but one unique row  (greg@turnstep.com)
Ответы Re: FAQ addition: deleteing all but one unique row  (greg@turnstep.com)
Список pgsql-patches
greg@turnstep.com writes:
> + <PRE>
> +        DELETE FROM mytable WHERE ctid !=
> +          (SELECT ctid FROM mytable WHERE id=12 LIMIT 1);
> + </PRE>
> +
> +     <P>In the above example, all rows in the table named 'mytable' having a value
> +        of 12 in the 'id' column will be deleted except for one.

You haven't actually tested this advice, have you?

The delete as given will delete all but one row, full stop.

Or at least it would if it worked at all.  There's no != operator
defined for CTID.  (You could get around that with "NOT ctid =".)

            regards, tom lane

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

Предыдущее
От: greg@turnstep.com
Дата:
Сообщение: FAQ addition: deleteing all but one unique row
Следующее
От: greg@turnstep.com
Дата:
Сообщение: Re: FAQ addition: deleteing all but one unique row