Re: How to delete duplicate record

Поиск
Список
Период
Сортировка
От greg@turnstep.com
Тема Re: How to delete duplicate record
Дата
Msg-id b1761f04edab6a7b6d95e10f1b696b49@biglumber.com
обсуждение исходный текст
Ответ на Re: How to delete duplicate record  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Список pgsql-sql
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Abdul Wahab Dahalan:
>> Here I've 7 duplicated records and tried to delete 6 from them.

Stephan Szabo:
> delete from biztypes where ctid in (select ctid from biztypes where
> bizid='B116' limit 6);

A more general form of the "delete all but one" is:

DELETE FROM biztypes WHERE ctid !=  (SELECT ctid FROM biztypes WHERE bizid='B116' LIMIT 1);

You can also usually use the oid column instead of the ctid column.

System columns explained:
http://www.gtsm.com/cgi/psearch?page=ddl-system-columns.html;q=ctid;c=0


- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200302100934

-----BEGIN PGP SIGNATURE-----
Comment: http://www.turnstep.com/pgp.html

iD8DBQE+R7oUvJuQZxSWSsgRAloaAJ9AkNjjYvCuOB8wanR8RoouEmU6eACg5YVX
3R+q3GDK5Pblu7L7z3TIEnE=
=qM8Y
-----END PGP SIGNATURE-----




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

Предыдущее
От: "Alexander Stanier"
Дата:
Сообщение: Referential Integrity
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Referential Integrity