[GENERAL] Adding PRIMARY KEY: Table contains duplicated values

2013-02-04 Thread Alexander Farber
Hello, when trying to add a forgotten primary key pair to a PostgreSQL 8.4.13 table I get the error: # \d pref_rep Table public.pref_rep Column |Type | Modifiers

Re: [GENERAL] Adding PRIMARY KEY: Table contains duplicated values

2013-02-04 Thread Adrian Klaver
On 02/04/2013 06:17 AM, Alexander Farber wrote: Hello, when trying to add a forgotten primary key pair to a PostgreSQL 8.4.13 table I get the error: # \d pref_rep Table public.pref_rep Column |Type |

Re: [GENERAL] Adding PRIMARY KEY: Table contains duplicated values

2013-02-04 Thread Alexander Farber
Thank you - On Mon, Feb 4, 2013 at 3:26 PM, Andrew Jaimes andrewjai...@hotmail.com wrote: SELECT id, author, count(1) FROM pref_rep GROUP BY id, author HAVING count(1) 1 From: alexander.far...@gmail.com

Re: [GENERAL] Adding PRIMARY KEY: Table contains duplicated values

2013-02-04 Thread Alexander Farber
Trying to delete the older of the duplicated pairs: # SELECT id, author, count(1), max(stamp) as maxx FROM pref_rep GROUP BY id, author HAVING count(1) 1 and stamp maxx; ERROR: column maxx does not exist LINE 4: HAVING count(1) 1 and stamp maxx; ^ On

Re: [GENERAL] Adding PRIMARY KEY: Table contains duplicated values

2013-02-04 Thread Adrian Klaver
On 02/04/2013 06:45 AM, Alexander Farber wrote: Trying to delete the older of the duplicated pairs: # SELECT id, author, count(1), max(stamp) as maxx FROM pref_rep GROUP BY id, author HAVING count(1) 1 and stamp maxx; ERROR: column maxx does not exist LINE 4: HAVING count(1) 1 and stamp

Re: [GENERAL] Adding PRIMARY KEY: Table contains duplicated values

2013-02-04 Thread Alexander Farber
Unfortunately that fails - On Mon, Feb 4, 2013 at 3:55 PM, Adrian Klaver adrian.kla...@gmail.com wrote: On 02/04/2013 06:45 AM, Alexander Farber wrote: Trying to delete the older of the duplicated pairs: How about: SELECT id, author, count(1), max(stamp) as maxx FROM pref_rep GROUP

Re: [GENERAL] Adding PRIMARY KEY: Table contains duplicated values

2013-02-04 Thread Adrian Klaver
On 02/04/2013 06:45 AM, Alexander Farber wrote: Trying to delete the older of the duplicated pairs: # SELECT id, author, count(1), max(stamp) as maxx FROM pref_rep GROUP BY id, author HAVING count(1) 1 and stamp maxx; ERROR: column maxx does not exist LINE 4: HAVING count(1) 1 and stamp

Re: [GENERAL] Adding PRIMARY KEY: Table contains duplicated values

2013-02-04 Thread Andreas Kretschmer
Alexander Farber alexander.far...@gmail.com wrote: # alter table pref_rep add primary key(id, author); NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index pref_rep_pkey for table pref_rep ERROR: could not create unique index pref_rep_pkey DETAIL: Table contains duplicated

Re: [GENERAL] Adding PRIMARY KEY: Table contains duplicated values

2013-02-04 Thread Andreas Kretschmer
Andreas Kretschmer akretsch...@spamfence.net wrote: Alexander Farber alexander.far...@gmail.com wrote: # alter table pref_rep add primary key(id, author); NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index pref_rep_pkey for table pref_rep ERROR: could not create unique

Re: [GENERAL] Adding PRIMARY KEY: Table contains duplicated values

2013-02-04 Thread Alexander Farber
Thank you - On Mon, Feb 4, 2013 at 5:06 PM, Andreas Kretschmer akretsch...@spamfence.net wrote: # alter table pref_rep add primary key(id, author); NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index pref_rep_pkey for table pref_rep ERROR: could not create unique index

Re: [GENERAL] Adding PRIMARY KEY: Table contains duplicated values

2013-02-04 Thread Andreas Kretschmer
Alexander Farber alexander.far...@gmail.com wrote: Thank you - On Mon, Feb 4, 2013 at 5:06 PM, Andreas Kretschmer akretsch...@spamfence.net wrote: # alter table pref_rep add primary key(id, author); NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index pref_rep_pkey for