Re: Delete duplicates

Поиск
Список
Период
Сортировка
От Sean Chittenden
Тема Re: Delete duplicates
Дата
Msg-id 20030623052256.GS97131@perrin.int.nxad.com
обсуждение исходный текст
Ответ на Re: Delete duplicates  ("Denis Arh" <denis@exonium.net>)
Список pgsql-sql
> How to delete "real" duplicates?
> 
> id | somthing
> -----------------------
> 1 | aaa
> 1 | aaa
> 2 | bbb
> 2 | bbb
> 
> (an accident with backup recovery...)

I'm not 100% on some of the syntax off the top of my head, but:

BEGIN;
ALTER TABLE orig_table RENAME TO backup_table;
CREATE TABLE orig_table AS SELECT id,something FROM backup_table GROUP BY id, something;
-- Create any indexes on orig_table that need to be recreated
DROP TABLE orig_table;
COMMIT;

This isn't for the faint of heart: be sure to do this inside of a
transaction or on a backup db until you're 100% good to go.  -sc
-- 
Sean Chittenden


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

Предыдущее
От: "Denis Arh"
Дата:
Сообщение: Re: Delete duplicates
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Delete duplicates