From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: jeff sacksteder <jsacksteder@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: alter sequence + subqueries
Date: Fri, 16 Sep 2005 19:19:08 -0400
Message-ID: <20050916231908.GE9069@surnet.cl> (raw)
In-Reply-To: <51c8a7be050916153613795e1a@mail.gmail.com>
References: <51c8a7be050916153613795e1a@mail.gmail.com>
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")
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: alvherre@alvh.no-ip.org, jsacksteder@gmail.com
Subject: Re: alter sequence + subqueries
In-Reply-To: <20050916231908.GE9069@surnet.cl>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox