Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 9CDDFB5DBFB for ; Tue, 14 Jun 2011 11:06:29 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 80655-09 for ; Tue, 14 Jun 2011 14:06:22 +0000 (UTC) X-Greylist: delayed 00:05:47.183848 by SQLgrey-1.7.6 Received: from mx01.bfk.de (mx01.bfk.de [193.227.124.2]) by mail.postgresql.org (Postfix) with ESMTP id B1B70B5DBF9 for ; Tue, 14 Jun 2011 11:06:22 -0300 (ADT) Received: from mx00.int.bfk.de ([10.119.110.2]) by mx01.bfk.de with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) id 1QWUAT-00064r-8x; Tue, 14 Jun 2011 14:00:33 +0000 Received: by bfk.de with local id 1QWUAT-00079p-51; Tue, 14 Jun 2011 14:00:33 +0000 From: Florian Weimer To: Leif Biberg Kristensen Cc: pgsql-sql@postgresql.org Subject: Re: Subselects not allowed? References: <201106111701.54145.leif@solumslekt.org> <201106112209.09813.leif@solumslekt.org> <201106121022.28759.leif@solumslekt.org> Date: Tue, 14 Jun 2011 14:00:33 +0000 In-Reply-To: <201106121022.28759.leif@solumslekt.org> (Leif Biberg Kristensen's message of "Sun, 12 Jun 2011 10:22:28 +0200") Message-ID: <82pqmgwm0u.fsf@mid.bfk.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201106/46 X-Sequence-Number: 35512 * Leif Biberg Kristensen: > And even better, in the first comment to the blog post, I was advised abo= ut the=20 > SETVAL() function which does exactly what I wanted in the first place. > > CREATE SEQUENCE persons_person_id_seq; > SELECT SETVAL('persons_person_id_seq', MAX(person_id)) FROM persons; > ALTER TABLE persons ALTER COLUMN person_id SET DEFAULT=20 > NEXTVAL('persons_person_id_seq'); > ALTER SEQUENCE persons_person_id_seq OWNED BY persons.person_id; I think you should acquire an exclusive lock on the table, too. --=20 Florian Weimer BFK edv-consulting GmbH http://www.bfk.de/ Kriegsstra=DFe 100 tel: +49-721-96201-1 D-76133 Karlsruhe fax: +49-721-96201-99