Re: how to reset the sequences of SERIAL vars? - Mailing list pgsql-general

From Shridhar Daithankar
Subject Re: how to reset the sequences of SERIAL vars?
Date
Msg-id 3DC2A269.24192.914266C@localhost
Whole thread Raw
In response to how to reset the sequences of SERIAL vars?  (Bruno Boettcher <bboett@bboett.dyndns.org>)
List pgsql-general
On 1 Nov 2002 at 10:59, Bruno Boettcher wrote:
>   when inserting from backup the tables are filled with all fields, this
>   means alos those defined as serial, but without using nextval...
>
>   this means that the sequences for those vars are out of synch with the
>   table after the backup...
>
>   now there was a sequence to set this up and runnign again, but i cna't
>   find it in my papers anymore, so if someone could kindly point me out
>   on how to set up the correct values un the sequence i will be really
>   grateful.

From createsequence.html in postgresql manual

---------------------------------------
 Update the sequence value after a COPY FROM:

BEGIN;
    COPY distributors FROM 'input_file';
    SELECT setval('serial', max(id)) FROM distributors;
END;
---------------------------------------

Also look at functions-sequence.html for more reference.

HTH



Bye
 Shridhar

--
Barometer, n.:    An ingenious instrument which indicates what kind of weather we
are having.        -- Ambrose Bierce, "The Devil's Dictionary"


pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: how to reset the sequences of SERIAL vars?
Next
From: mail2stern@gmx.net (Stefan Stern)
Date:
Subject: readline.h and history.h configure error