Обсуждение: Deleting duplicate records
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). -------------------------------------------
"Paul S. Ganney" <paul.ganney@dial.pipex.com> 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