Deleting duplicate records

Поиск
Список
Период
Сортировка
Искать

Deleting duplicate records

От:
"Paul S. Ganney" <paul.ganney@dial.pipex.com>
Дата:
This probably sounds horribly trivial, but still...

I've managed to get some duplicate records in a table and am having 
problems getting rid of them (as there's nothing unique to SELECT on). 
Any ideas?

And whilst I'm at it - any ideas on a scheme for preventing duplicates?

Paul.
-- 
-------------------------------------------
Expressed opinions are usually my own.
Especially if they're any good (of course).
-------------------------------------------


Re: [INTERFACES] Deleting duplicate records

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Paul S. Ganney"  writes:
> I've managed to get some duplicate records in a table and am having 
> problems getting rid of them (as there's nothing unique to SELECT on). 
> Any ideas?

There's always the OID.  Doselect oid,* from table ...
to see it, and get rid of the unwanted rows withdelete from table where oid = nnnn;

> And whilst I'm at it - any ideas on a scheme for preventing duplicates?

Unique index on whatever combination of fields is your primary key?
		regards, tom lane

FAQ