Sequence reset

Started by SUNDAY A. OLUTAYOover 15 years ago5 messagesgeneral
Jump to latest
#1SUNDAY A. OLUTAYO
olutayo@sadeeb.com

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

Sunday Olutayo
Sadeeb Technologies Ltd

In reply to: SUNDAY A. OLUTAYO (#1)
Re: Sequence reset

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

#3Scott Marlowe
scott.marlowe@gmail.com
In reply to: SUNDAY A. OLUTAYO (#1)
Re: Sequence reset

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.

#4Randall Smith
randall@tnr.cc
In reply to: SUNDAY A. OLUTAYO (#1)
Re: Sequence reset

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

Show quoted text

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

#5Rikard Bosnjakovic
rikard.bosnjakovic@gmail.com
In reply to: SUNDAY A. OLUTAYO (#1)
Re: Sequence reset

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