From: Paul Lambert <paul.lambert@autoledgers.com.au>
To: Andrew Sullivan <ajs@crankycanuck.ca>
Cc: pgsql-sql@postgresql.org
Subject: Re: Removing duplicate rows
Date: Wed, 07 Feb 2007 07:44:09 +0900
Message-ID: <45C904B9.40407@autoledgers.com.au> (raw)
In-Reply-To: <20070206222238.GA28647@phlogiston.dyndns.org>
References: <45C8FDE6.6050603@autoledgers.com.au>
<20070206222238.GA28647@phlogiston.dyndns.org>
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
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: paul.lambert@autoledgers.com.au, ajs@crankycanuck.ca
Subject: Re: Removing duplicate rows
In-Reply-To: <45C904B9.40407@autoledgers.com.au>
* 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