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 5390ED9206 for ; Fri, 16 Sep 2005 20:18:07 -0300 (ADT) 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 95231-08 for ; Fri, 16 Sep 2005 23:18:01 +0000 (GMT) Received: from mx1.surnet.cl (mx2.surnet.cl [216.155.73.181]) by svr1.postgresql.org (Postfix) with ESMTP id F34B9D90A9 for ; Fri, 16 Sep 2005 20:18:02 -0300 (ADT) Received: from unknown (HELO cluster.surnet.cl) ([216.155.73.165]) by mx1.surnet.cl with ESMTP; 16 Sep 2005 19:17:49 -0400 X-IronPort-AV: i="3.97,114,1125892800"; d="scan'208"; a="10070389:sNHT31889040" Received: from alvh.no-ip.org (216.155.78.171) by cluster.surnet.cl (7.0.043) (authenticated as alvherre@surnet.cl) id 4327E85F0005C473; Fri, 16 Sep 2005 19:18:04 -0400 Received: by alvh.no-ip.org (Postfix, from userid 1000) id 20686C30F8C; Fri, 16 Sep 2005 19:19:08 -0400 (CLT) Date: Fri, 16 Sep 2005 19:19:08 -0400 From: Alvaro Herrera To: jeff sacksteder Cc: pgsql-sql@postgresql.org Subject: Re: alter sequence + subqueries Message-ID: <20050916231908.GE9069@surnet.cl> Mail-Followup-To: jeff sacksteder , pgsql-sql@postgresql.org References: <51c8a7be050916153613795e1a@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <51c8a7be050916153613795e1a@mail.gmail.com> User-Agent: Mutt/1.5.10i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.877 required=5 tests=[AWL=0.077, DNS_FROM_RFC_ABUSE=0.374, DNS_FROM_RFC_POST=1.376, FORGED_RCVD_HELO=0.05] X-Spam-Level: * X-Archive-Number: 200509/168 X-Sequence-Number: 22715 On Fri, Sep 16, 2005 at 06:36:48PM -0400, jeff sacksteder wrote: > The postgres-specific sql extension 'ALTER SEQUENCE' does not appear to > support subqueries. > > I have inserted some data into a table, including values in the primary key. > I want to reset the associated sequence so that any further records to be > inserted into that table resume numbering correctly. The statement I > attempted was: > > ALTER SEQUENCE foo_id_seq > RESTART WITH (SELECT max(id) FROM foo); > > Is this syntax correct and supported? No, but you could call the setval() function instead ... -- Alvaro Herrera -- Valdivia, Chile Architect, www.EnterpriseDB.com Officer Krupke, what are we to do? Gee, officer Krupke, Krup you! (West Side Story, "Gee, Officer Krupke")