Обсуждение: Re: [SQL] Setting Next Value in Sequence
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 -----Original Message----- From: Remigiusz Sokolowski <rems@gdansk.sprint.pl> To: Tim Perdue <perdue@raccoon.com> Cc: pgsql-sql@hub.org <pgsql-sql@hub.org> Date: Tuesday, March 16, 1999 6:57 AM Subject: Re: [SQL] Setting Next Value in Sequence >> Maybe it's due to sleep deprivation, but this is not working. I'm trying to >> update a seqence to a higher number, and it won't let me. >> >> db_domain=> update seq_mailid set last_value=1375000; >> ERROR: You can't change sequence relation seq_mailid >> >> My sense of humor has totally faded over the last two days, and I would >> appreciate sone input. > >So, may be just drop sequence and create new one with start 1375000. > Rem > >-------------------------------------------------------------------*------- ----- >Remigiusz Sokolowski e-mail: rems@gdansk.sprint.pl * * >-----------------------------------------------------------------*****----- -----
At 15:06 +0200 on 16/3/99, Tim Perdue wrote: > 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. What? You just need to drop and create a sequence with the same name. At least it works for me (though I noticed that unprivileged users have problems creating tables without having the sequences created first, which IMHO is a bug. But I don't think it applies to already-created tables). Herouth -- Herouth Maoz, Internet developer. Open University of Israel - Telem project http://telem.openu.ac.il/~herutma
> > 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@gdansk.sprint.pl * * -----------------------------------------------------------------*****----------