X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D29CEDAD1C for ; Thu, 10 Nov 2005 11:58:28 -0400 (AST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 57094-06 for ; Thu, 10 Nov 2005 15:58:24 +0000 (GMT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from svr2.postgresql.org (svr2.postgresql.org [65.19.161.25]) by svr1.postgresql.org (Postfix) with ESMTP id 1AA7FDABE9 for ; Thu, 10 Nov 2005 11:58:26 -0400 (AST) Received: from ll.mit.edu (LLMAIL.LL.MIT.EDU [129.55.12.40]) by svr2.postgresql.org (Postfix) with ESMTP id E6DC8F1190 for ; Thu, 10 Nov 2005 15:58:31 +0000 (GMT) Received: (from smtp@localhost) by ll.mit.edu (8.12.10/8.8.8) id jAAFwT0j029875 for ; Thu, 10 Nov 2005 10:58:29 -0500 (EST) Received: from UNKNOWN( ), claiming to be "sty.llan" via SMTP by llmail, id smtpdAAAeBaWT5; Thu Nov 10 10:58:18 2005 Date: Thu, 10 Nov 2005 10:58:18 -0500 From: george young To: pgsql-sql@postgresql.org Subject: how to update table to make dup values distinct Message-Id: <20051110105818.4dc51e8c.gry@ll.mit.edu> Reply-To: gry@ll.mit.edu Organization: MIT Lincoln Laboratory X-Mailer: Sylpheed version 2.0.1 (GTK+ 2.8.0; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.004 required=5 tests=[AWL=0.003, UNPARSEABLE_RELAY=0.001] X-Spam-Score: 0.004 X-Spam-Level: X-Archive-Number: 200511/87 X-Sequence-Number: 23338 [PostgreSQL 7.4RC2 on i686-pc-linux-gnu](I know, I know... must upgrade soon) I have a table mytable like: i | txt ---+------- 1 | the 2 | the 3 | rain 4 | in 5 | mainly 6 | spain 7 | stays 8 | mainly 9 | in I want to update it, adding a ':' to txt so that each txt value is unique. I don't care which entry gets changed. I tried: update mytable set txt=mytable.txt || ':' from mytable t2 where mytable.txt=t2.txt and mytable.i=t2.i; but this updated both duplicated entries. Um, there may sometimes be 3 or 4 duplicates, not just two. For these, I can add multiple colons, or one each of an assortment of characters, say ':+*&^#'. Performance does not matter here. The real table has 30K rows, ~200 dups. To clarify, I want to end up with something like: 1 | the 2 | the: 3 | rain 4 | in 5 | mainly: 6 | spain 7 | stays 8 | mainly 9 | in: -- George -- "Are the gods not just?" "Oh no, child. What would become of us if they were?" (CSL)