Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id D69189FB290 for ; Tue, 6 Feb 2007 18:45:18 -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 36984-02 for ; Tue, 6 Feb 2007 18:45:11 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from rrmailscan3.safenetbox.biz (unknown [203.25.40.75]) by postgresql.org (Postfix) with ESMTP id 3BEBE9F9FE2 for ; Tue, 6 Feb 2007 18:45:07 -0400 (AST) Received: from rrmailscan3.safenetbox.biz (rrmailscan3.safenetbox.biz [127.0.0.1]) by rrmailscan3.safenetbox.biz (Postfix) with ESMTP id C9FE41D48446; Wed, 7 Feb 2007 09:45:07 +1100 (EST) Received: from [172.17.2.14] (online4-new.lnk.telstra.net [139.130.169.227]) (Authenticated sender: remote) by rrmailscan3.safenetbox.biz (Postfix) with ESMTP id 23D021D4843A; Wed, 7 Feb 2007 09:45:06 +1100 (EST) Message-ID: <45C904B9.40407@autoledgers.com.au> Date: Wed, 07 Feb 2007 07:44:09 +0900 From: Paul Lambert User-Agent: Thunderbird 1.5.0.8 (Windows/20061025) MIME-Version: 1.0 To: Andrew Sullivan CC: pgsql-sql@postgresql.org Subject: Re: Removing duplicate rows References: <45C8FDE6.6050603@autoledgers.com.au> <20070206222238.GA28647@phlogiston.dyndns.org> In-Reply-To: <20070206222238.GA28647@phlogiston.dyndns.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/57 X-Sequence-Number: 27391 Andrew Sullivan wrote: > 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, Sort on Weenblows is a bastard to work with, and I don't believe it has a unique option. I probably should have mentioned this was on Weenblows. > >> 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.) Thanks... I figured it would be blatantly obvious. This does the trick: CREATE TABLE billing_code_temp AS SELECT * FROM billing_code WHERE 1=0 > > A > Appreciate the help. P. -- Paul Lambert Database Administrator AutoLedgers