Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 4F5F447590F for ; Fri, 26 Apr 2002 12:14:38 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.4/8.11.4) with ESMTP id g3QGEdF26780; Fri, 26 Apr 2002 12:14:39 -0400 (EDT) To: nickf@ontko.com Cc: "PGSQL-SQL" Subject: Re: How do I create unique IDs for an existing set of records In-reply-to: References: Comments: In-reply-to "Nick Fankhauser" message dated "Fri, 26 Apr 2002 10:58:16 -0500" Date: Fri, 26 Apr 2002 12:14:39 -0400 Message-ID: <26777.1019837679@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200204/327 X-Sequence-Number: 7591 "Nick Fankhauser" writes: > I tried: > update test set new_pk = (select nextval('test_new_pk_seq')); > but it wants to update *all* of the rows to the current nextval (I was > hoping it would evaluate nextval on each row). Yeah, the sub-select is taken (perhaps mistakenly) as something that can be evaluated only once, because it doesn't depend on the outer query. You are overthinking the problem; this should work: update test set new_pk = nextval('test_new_pk_seq'); regards, tom lane