From: | Said Ramirez <sramirez(at)vonage(dot)com> |
---|---|
To: | A B <gentosaker(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: How to remove duplicate lines but save one of the lines? |
Date: | 2008-07-21 16:14:12 |
Message-ID: | 4884B5D4.5030901@vonage.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Yes, here foo is a temp table. As others have pointed out, you could
probably do a create table foo as select distinct * from orig_table. I
would move the data back to orig_table, so that constraints and
privileges are maintainited. After you have done this, you can put a
uniq constraint on columns A & B. I am uncertain if you can do
something like ALTER TABLE orig_table ADD UNIQUE (A,B) ON DUPLICATE DELETE.
-Said
A B wrote:
> > There is probably a more elegant way of doing it, but a simple way
> of doing
> > it ( depending on the size of the table ) could be:
> >
> > begin;
> >
> > insert into foo select distinct * from orig_table;
> > delete from orig_table;
> > insert into orig_table select * from foo;
> >
> > commit;
>
> Just to make it clear to me
> Here foo is a table that I have to create with the command
> CREATE TABLE foo (....same columns as orig_table);
> ?
>
> Is it possible to add a unique constraint to the table, with a
> "delete" option so it will delete duplicates?
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
--
Said Ramirez
Super Cool MySQL DBA
cel: 732 425 1929
From | Date | Subject | |
---|---|---|---|
Next Message | Hoover, Jeffrey | 2008-07-21 16:14:48 | Re: How to remove duplicate lines but save one of the lines? |
Previous Message | Scott Marlowe | 2008-07-21 16:13:29 | Re: Problems using Grails with Postgresql |