Re: how to reset serials

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Joseph Syjuco <joseph(at)asti(dot)dost(dot)gov(dot)ph>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: how to reset serials
Date: 2002-06-06 11:48:24
Message-ID: 20020606114824.GA8206@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thu, Jun 06, 2002 at 20:03:49 -0400,
Joseph Syjuco <joseph(at)asti(dot)dost(dot)gov(dot)ph> wrote:
> how can i reset my serial field to 0. Tried using setval but it only
> allows setting of my next serial to 2
> joseph

From the 7.2.1 documentation:
SELECT setval('foo', 42); Next nextval() will return 43
SELECT setval('foo', 42, true); Same as above
SELECT setval('foo', 42, false); Next nextval() will return 42

So you want to use (assuming you really want the next value to be 1):
SELECT setval('your_sequence', 1, false);

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Jan Wieck 2002-06-06 12:20:55 Re: extract and variables in PL/pgSQL
Previous Message D'Arcy J.M. Cain 2002-06-06 10:34:35 Re: PostgreSQL on AIX