From: | Hariraman Jayaraj <hariraman(dot)ocp(at)gmail(dot)com> |
---|---|
To: | "Arun P(dot)L" <arunpl(at)hotmail(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Delete duplicate records with same fields |
Date: | 2013-08-29 12:15:50 |
Message-ID: | CAGy0Tff=fpCGNStzAr=rgkNdEJzTwJipikJGAs_C8GcSJiEBzA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
For finding duplicates you can use ctid.
select o.ctid, o.a, o.b from test o
where exists ( select 'x'
from test i
where i.a = o.a
and i.b = o.b
and i.ctid < o.ctid
);
for deleting,
delete from test
where exists ( select 'x'
from test i
where i.a = test.a
and i.b = test.b
and i.ctid < test.ctid
);
On Thu, Aug 29, 2013 at 5:09 PM, Arun P.L <arunpl(at)hotmail(dot)com> wrote:
> Hi all,
>
> Is there any way to delete duplicate rows in psql with no unique fields?
> I have a set of old records with their duplicates in my db and they are
> all having the same fields. How can I delete duplicates?
>
> Thanks in Advance,
> Arun
>
--
Hari
From | Date | Subject | |
---|---|---|---|
Next Message | Bocap | 2013-08-29 13:54:26 | Using of replication by initdb for both nodes? |
Previous Message | Arun P.L | 2013-08-29 11:39:02 | Delete duplicate records with same fields |