Received: from Kitten.mcs.com (Kitten.mcs.com [192.160.127.90]) by hub.org (8.9.1/8.9.1) with ESMTP id PAA22105 for ; Thu, 3 Dec 1998 15:02:09 -0500 (EST) (envelope-from les@Mercury.mcs.net) Received: from Mercury.mcs.net (les@Mercury.mcs.net [192.160.127.80]) by Kitten.mcs.com (8.8.7/8.8.2) with ESMTP id OAA04804; Thu, 3 Dec 1998 14:02:06 -0600 (CST) Received: (from les@localhost) by Mercury.mcs.net (8.8.7/8.8.2) id OAA26371; Thu, 3 Dec 1998 14:02:06 -0600 (CST) From: Leslie Mikesell Message-Id: <199812032002.OAA26371@Mercury.mcs.net> Subject: Re: Re[2]: [SQL] Query to eliminate duplicates To: mjnf@uevora.pt Date: Thu, 3 Dec 1998 14:02:06 -0600 (CST) Cc: sferac@bo.nettuno.it, pgsql-sql@postgreSQL.org In-Reply-To: from "Mario Filipe" at Dec 3, 98 03:07:50 pm X-Mailer: ELM [version 2.4 PL24] Content-Type: text 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