[NOVICE] Skipping numbers in a sequence. - Mailing list pgsql-general

From GH
Subject [NOVICE] Skipping numbers in a sequence.
Date
Msg-id 20001123134415.F30801@over-yonder.net
Whole thread Raw
Responses Re: [NOVICE] Skipping numbers in a sequence.
List pgsql-general
Hello all.

It's like this. ;-)

I have a table with a column that has a default nextval('sequence').
The sequence is a standard increment 1 cycle sequence.

What happens when
    the sequence wraps after inserting the
        2-million-and-whatever-th row
    some of the earlier
        rows (say, 1-100) are still in the table
    but other rows or sections (say, 101-110 and 120-125) have
        been deleted
and I need to begin with the first un-used sequence number?

I suppose that I would need to find the first un-used sequence number,
use setval() to update the sequence, and then insert the row that needs
to be insert-ed. Well, how can I find the first un-used sequence number?
I thought about doing something using a function like
    select sequence_column from table
    NOT [the set of numbers that make up the sequence]
but, how do I select the set of numbers that make up the sequence?

Is there a better/cleaner/easier way of getting the end result?

Postgres 7.0.2 (should be running .3, *sigh*)
FreeBSD 4.1-RELEASE
PHP 4.0.3pl1

Thanks fellas (and ladies, if applicable).

gh


pgsql-general by date:

Previous
From: GH
Date:
Subject: Re: plz, Help!! HOW CAN I GET THE ROWNUM IN POSTGRES TABLE AS I DID WITH ORACLE!!
Next
From: "Igor' Robul'"
Date:
Subject: Re: plz, Help!! HOW CAN I GET THE ROWNUM IN POSTGRES TABLE AS I DID WITH ORACLE!!