| From: | GH <grasshacker(at)over-yonder(dot)net> |
|---|---|
| To: | pgsql-novice(at)postgresql(dot)org |
| Subject: | [NOVICE] Skipping numbers in a sequence. |
| Date: | 2000-11-23 19:44:15 |
| Message-ID: | 20001123134415.F30801@over-yonder.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general pgsql-novice |
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Eisentraut | 2000-11-23 20:13:09 | Re: pgaccess |
| Previous Message | Jose Manuel Lorenzo Lopez | 2000-11-23 18:24:03 | Compiling postgresql 7.0.3 for WinNT |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Paul McGarry | 2000-11-24 04:17:59 | Re: re : PHP and persistent connections |
| Previous Message | Alfred Perlstein | 2000-11-23 19:31:53 | Re: startup script for FreeBSD |