Thread: Sequence reset

Sequence reset

From
"SUNDAY A. OLUTAYO"
Date:
How can I reset a sequence column due to deletion of some rolls?

Sunday Olutayo
Sadeeb Technologies Ltd

Re: Sequence reset

From
Raymond O'Donnell
Date:
On 23/08/2010 11:04, SUNDAY A. OLUTAYO wrote:
> How can I reset a sequence column due to deletion of some rolls?

You can use the setval() function to set its value to whatever you like:

http://www.postgresql.org/docs/8.4/static/functions-sequence.html

HTH

Ray.


--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie

Re: Sequence reset

From
Scott Marlowe
Date:
On Mon, Aug 23, 2010 at 4:04 AM, SUNDAY A. OLUTAYO <olutayo@sadeeb.com> wrote:
> How can I reset a sequence column due to deletion of some rolls?

Note that a design of a column that holds the output of a sequence and
can't handle gaps is pretty much broken.

Re: Sequence reset

From
Randall Smith
Date:
I can't tell what a roll is based on your question, but here is how to
set a sequence to a specific value.

SELECT setval('foo', 42);           Next nextval will return 43

http://www.postgresql.org/docs/8.4/interactive/functions-sequence.html

-Randall

On Mon, 2010-08-23 at 05:04 -0500, SUNDAY A. OLUTAYO wrote:
> How can I reset a sequence column due to deletion of some rolls?
>
> Sunday Olutayo
> Sadeeb Technologies Ltd
>



Re: Sequence reset

From
Rikard Bosnjakovic
Date:
On Mon, Aug 23, 2010 at 12:04, SUNDAY A. OLUTAYO <olutayo@sadeeb.com> wrote:

> How can I reset a sequence column due to deletion of some rolls?

ALTER SEQUENCE sequence_name RESTART 1;


--
- Rikard