Re: Duplicate rows

Поиск
Список
Период
Сортировка
От Andreas Kretschmer
Тема Re: Duplicate rows
Дата
Msg-id 20100810194433.GA2021@tux
обсуждение исходный текст
Ответ на Duplicate rows  ("Edward W. Rouse" <erouse@comsquared.com>)
Ответы Re: Duplicate rows
Список pgsql-sql
Edward W. Rouse <erouse@comsquared.com> wrote:

> Is there any way to remove a duplicate row from a table? Not my db but I have
> to work with it. On version 7.4 right now.
> 

How to select the right records?

You can try to use the ctid-column, see my simple example:

test=# select * from dups ;i
---1112234
(7 Zeilen)

Zeit: 0,145 ms
test=*# delete from dups where (ctid, i) not in (select max(ctid), i from dups group by i);
DELETE 3
Zeit: 0,378 ms
test=*# select * from dups ;i
---1234
(4 Zeilen)



Andreas
-- 
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect.                              (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly."   (unknown)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°


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

Предыдущее
От: "Edward W. Rouse"
Дата:
Сообщение: Duplicate rows
Следующее
От: msi77
Дата:
Сообщение: Re: Duplicate rows