Re: FW: reset all sequences

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Pascal Tufenkji <ptufenkji(at)usj(dot)edu(dot)lb>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: FW: reset all sequences
Date: 2006-05-09 06:42:38
Message-ID: 20060508234048.E49285@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Tue, 9 May 2006, Pascal Tufenkji wrote:

> How can I reset the sequence to "1"
>
> If I use the following statement
>
> Select setval('mytable_id_seq',1);
>
> I put the last value as 1
>
> So when I insert a new row the value will be "2" and not "1" as it should be
>
> I cannot put Select setval('mytable_id_seq',0);
>
> What should I do ??!!

You should be able to do this with the three argument form of setval as
setval('mytable_id_seq',1,false).

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Thusitha Kodikara 2006-05-09 07:21:29 Re: FW: reset all sequences
Previous Message Pascal Tufenkji 2006-05-09 06:38:24 FW: reset all sequences