Re: Deleting one of 2 identical records

From: Thom Brown <thom(at)linux(dot)com>
To: salah jubeh <s_jubeh(at)yahoo(dot)com>
Cc: "Gauthier, Dave" <dave(dot)gauthier(at)intel(dot)com>, Andy Colson <andy(at)squeakycode(dot)net>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Deleting one of 2 identical records
Date: 2011-09-07 00:05:57
Message-ID: CAA-aLv6PaYB4VxSfVZGi=ghZkHX8P86txRDwcZk=s5gfvk2SvQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 7 September 2011 00:55, salah jubeh <s_jubeh(at)yahoo(dot)com> wrote:

>
> Hello Thom.
>
> what is the meaning of
>
> select table_name from table_name
>
> Also is this a common behavior of all Databases i.e. oracle , Microsoft
> ,...etc . i.e is this is the standard behavior
>
> I think this is a good way to find duplicates in general, I will write a
> routine to compare all the columns by excluding the primary key which is
> serial
>
> Thanks in advance
>

Well I just put table_name as a placeholder for the actual name of the table
you wish to remove duplicates from.

No, you can't run this query on other databases, particularly because ctids
are specific to PostgreSQL. Other databases will use different methods to
this one, if they have any at all. With Oracle you'd probably use ROWNUM
somehow, and SQL Server will likely use some awful multi-query technique
involving creating temporary tables, copying distinct rows from the
duplicate set to another table, deleting it from the original and copying
back. Can't say for sure though since I haven't used it in quite a while.

--
Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2011-09-07 00:58:29 Re: Which perl works with pg9.1
Previous Message salah jubeh 2011-09-06 23:55:47 Re: Deleting one of 2 identical records