Обсуждение: Sequence reset

Поиск
Список
Период
Сортировка

Sequence reset

От
"SUNDAY A. OLUTAYO"
Дата:
How can I reset a sequence column due to deletion of some rolls?

Sunday Olutayo
Sadeeb Technologies Ltd

Re: Sequence reset

От
Raymond O'Donnell
Дата:
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

От
Scott Marlowe
Дата:
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

От
Randall Smith
Дата:
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

От
Rikard Bosnjakovic
Дата:
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