pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Leslie Mikesell <les@Mcs.Net>
To: mjnf@uevora.pt
Cc: sferac@bo.nettuno.it
Cc: pgsql-sql@postgreSQL.org
Subject: Re: Re[2]: [SQL] Query to eliminate duplicates
Date: Thu, 3 Dec 1998 14:02:06 -0600 (CST)
Message-ID: <199812032002.OAA26371@Mercury.mcs.net> (raw)
In-Reply-To: <XFMail.981203150750.mjnf@uevora.pt>

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@mcs.com



view thread (3+ messages)

Message-ID: <199812032002.OAA26371@Mercury.mcs.net>
Permalink:  ../199812032002.OAA26371@Mercury.mcs.net/
Also on:    postgresql.org/message-id/199812032002.OAA26371@Mercury.mcs.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: les@Mcs.Net, mjnf@uevora.pt, sferac@bo.nettuno.it
  Subject: Re: [SQL] Query to eliminate duplicates
  In-Reply-To: <199812032002.OAA26371@Mercury.mcs.net>
  References: <XFMail.981203150750.mjnf@uevora.pt> <199812032002.OAA26371@Mercury.mcs.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox