From: | Leslie Mikesell <les(at)Mcs(dot)Net> |
---|---|
To: | mjnf(at)uevora(dot)pt |
Cc: | sferac(at)bo(dot)nettuno(dot)it, pgsql-sql(at)postgreSQL(dot)org |
Subject: | Re: Re[2]: [SQL] Query to eliminate duplicates |
Date: | 1998-12-03 20:02:06 |
Message-ID: | 199812032002.OAA26371@Mercury.mcs.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
According to Mario Filipe:
>
> >>> MF> Is there a way to eliminate duplicate records using just SQL?
> >>>
> >>> SELECT DISTINCT ...
> >
> >
> > MF> The problem is that i have a table where there are duplicate
> > records
> > MF> and i want to delete them! I tryed creating a unique index but it told me
> > it
> > MF> couldn't because it didn't have a function to do something (I think it is
> > MF> because i had a boolean field in it)
>
> So a duplicate is actually a record that looks exactly like other record on the
> table...
How about:
select distinct * into newtable from oldtable ;
drop table oldtable;
alter table newtable rename to oldtable;
You have to drop/create indexes separately, even the ones built
implicitly from 'primary key' directives.
Les Mikesell
les(at)mcs(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 1998-12-03 23:23:37 | Re: [SQL] Optimizations |
Previous Message | Barracuda | 1998-12-03 19:53:49 | RE: Re[2]: [SQL] Please help: How to determine largest of two num bers in a query? |