Re: [SQL] Setting Next Value in Sequence

From: Remigiusz Sokolowski <rems(at)gdansk(dot)sprint(dot)pl>
To: Tim Perdue <perdue(at)raccoon(dot)com>
Cc: pgsql-sql(at)hub(dot)org
Subject: Re: [SQL] Setting Next Value in Sequence
Date: 1999-03-16 13:25:20
Message-ID: Pine.GS4.4.02A.9903161418230.25425-100000@netra.gdansk.sprint.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

>
> May table is defined to use the sequence, and the table is not trivial to
> export and rebuild with the new sequence.
>
> There's got to be some way around this. I'm probably going to have to create
> a bogus table using that sequence, then insert 150,000 bogus records to
> increment the sequence. Then drop the table.
>
> Tim
AFAIK if You don't use serial type You can just drop sequence and create
new with the same name. Of course You need increase start value of this
sequence to get right value at next insert.
I think there is no some secret conjunction between sequence and table
which use it, so if You replace Your sequence with new one of the same
name, there should be no problems.

CREATE SEQUENCE your_prev_seq START your_next_val_from_table;

Naturally if You use serial type - there may be some problems with such
work around.
I don't understand, why You want to drop table - do You use serial
type?
Rem
-------------------------------------------------------------------*------------
Remigiusz Sokolowski e-mail: rems(at)gdansk(dot)sprint(dot)pl * *
-----------------------------------------------------------------*****----------

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tim Perdue 1999-03-16 14:17:55 Re: [SQL] Setting Next Value in Sequence
Previous Message Herouth Maoz 1999-03-16 13:23:52 Re: [SQL] Setting Next Value in Sequence