Re: setval('myfunsequence', 0)

From: "Ian Harding" <ianh(at)tpchd(dot)org>
To: <scott(dot)marlowe(at)ihs(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: setval('myfunsequence', 0)
Date: 2002-12-06 16:03:12
Message-ID: sdf059f5.001@mail.tpchd.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Argh! Sorry. I should RTFM!

>>> "scott.marlowe" <scott(dot)marlowe(at)ihs(dot)com> 12/06/02 07:53AM >>>
On Fri, 6 Dec 2002, Ian Harding wrote:

> The subject statement does not work for automagically generated sequences (minvalue is 1 by default, it seems.) I need to reset a sequence to where nextval('myfunsequence') is 1, and the only way to do it (I think) is to setval('myfunsequence', 0).
>
> I can just create this particular sequence with minvalue 0 start 1, but I am wondering what is the downside to this being the default? Alternatively, is there a way to make setval accept a value that is $start - $increment as seems to happen on creation?
>

Not true. Take a look at:
http://developer.postgresql.org/docs/postgres/functions-sequence.html

And note near the bottom, that you can setval with a third boolean value,
like so:

SELECT setval('foo', 1, false);

and the next nextval() will return 1

Browse pgsql-general by date

  From Date Subject
Next Message Jean-Luc Lachance 2002-12-06 16:18:24 Re: Order of execution of Constraints, Triggers and Rules
Previous Message scott.marlowe 2002-12-06 15:53:04 Re: setval('myfunsequence', 0)