Re: Deleting one of 2 identical records

Поиск
Список
Период
Сортировка
От Andy Colson
Тема Re: Deleting one of 2 identical records
Дата
Msg-id 4E665DC8.6010104@squeakycode.net
обсуждение исходный текст
Ответ на Deleting one of 2 identical records  ("Gauthier, Dave" <dave.gauthier@intel.com>)
Список pgsql-general
On 9/6/2011 12:39 PM, Gauthier, Dave wrote:
> Hi:
>
> If I have a table that has 2 records which are identical with regard to
> all their column values, is there a way to delete one of them, leaving
> one remaining? Is there some unique record_id key of some sort I can use
> for somethign like this?
>
> Thanks in Advance!
>

Not easily that I know of.  I have two thoughts:

1)
create table junk (like orig);
insert into junk select distinct from orig;
delete from orig where exists(select from junk);
insert into orig select * from junk;

2)
alter table orig add uid integer;
create sequence bob;
update orig set uid = nextval('bob');
drop sequence bob;
-- magic to delet using uid

Ah, Thom just answered.  I like his better, but I'll post this just for
completeness...

-Andy

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

Предыдущее
От: Thom Brown
Дата:
Сообщение: Re: Deleting one of 2 identical records
Следующее
От: Andy Colson
Дата:
Сообщение: Re: Deleting one of 2 identical records