Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 0F2459FB2CC for ; Tue, 6 Feb 2007 18:22:48 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 32674-02 for ; Tue, 6 Feb 2007 18:22:46 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from main2.mycybernet.net (main2.mycybernet.net [209.222.63.140]) by postgresql.org (Postfix) with ESMTP id 2375B9FB1BC for ; Tue, 6 Feb 2007 18:22:44 -0400 (AST) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227] helo=phlogiston.dydns.org) by main2.mycybernet.net with esmtp (Exim 4.62) (envelope-from ) id 1HEYtr-00042m-TA for pgsql-sql@postgresql.org; Tue, 06 Feb 2007 17:34:55 -0500 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 72F984051; Tue, 6 Feb 2007 17:22:38 -0500 (EST) Date: Tue, 6 Feb 2007 17:22:38 -0500 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: Removing duplicate rows Message-ID: <20070206222238.GA28647@phlogiston.dyndns.org> References: <45C8FDE6.6050603@autoledgers.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <45C8FDE6.6050603@autoledgers.com.au> User-Agent: Mutt/1.5.9i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/56 X-Sequence-Number: 27390 On Wed, Feb 07, 2007 at 07:15:02AM +0900, Paul Lambert wrote: > > I'm assuming the best way to get around this is to load the data into a > temporary table with "copy from" and then do a "select distinct into" my > real table. You might find that sort|uniq at the command prompt would be better. That said, > script to create the table as a copy of the existing 'real' table. I'm > assuming "create table as" would be what I need to use, but what would I > use as the select sql - i.e. how do I use select to pull the definition > of a table. an easy way to do this is "CREATE TABLE name AS SELECT . . . WHERE 1=0". You get a table with no rows. (WHERE FALSE and similar constructs all work equally well.) A -- Andrew Sullivan | ajs@crankycanuck.ca In the future this spectacle of the middle classes shocking the avant- garde will probably become the textbook definition of Postmodernism. --Brad Holland