Re: Reset sequence number

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: missive(at)hotmail(dot)com
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Reset sequence number
Date: 2002-02-25 15:28:48
Message-ID: 20020225152848.GA31650@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Sat, Feb 23, 2002 at 05:07:34PM +0000,
Lee Harr <missive(at)frontiernet(dot)net> wrote:
> > How can I reset a sequence number back to 0 ?
> >
>
> SELECT setval('sequence_name', 0);
>
>
> In order for this to work, the sequence must have been created with
> a MINVALUE of 0 (the default MINVALUE is 1)
>
> CREATE SEQUENCE sequence_name MINVALUE 0;

Note, that if you do it this way, 1 will be the next sequent number returned
by nextval. If you want 0 to be returned next use setval('seq_name', 0, false).

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Trevor Astrope 2002-02-25 16:20:59 Help pg_restore
Previous Message Zeugswetter Andreas SB SD 2002-02-25 12:04:30 Re: Backup and Recovery (revisited)