Re: Sequence not updated after a copy ?

From: Jeff Eckermann <jeff_eckermann(at)yahoo(dot)com>
To: GRIMOIS Eric <eric(dot)grimois(at)cpam-cergypontoise(dot)cnamts(dot)fr>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Sequence not updated after a copy ?
Date: 2002-03-21 20:34:13
Message-ID: 20020321203413.58637.qmail@web20806.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


--- GRIMOIS Eric
<eric(dot)grimois(at)cpam-cergypontoise(dot)cnamts(dot)fr> wrote:
> Hi All
>
> Does 'COPY table FROM...' command update the
> last_value field of the
> sequence(s) related to the table ?

No. I assume you have specified values in your source
file that take the place of the sequence-supplied
values, otherwise the COPY operation would almost
certainly fail.

> Is a setval( ) function required after completion ?

Yes: preferably before, if you want the sequence to be
available to other users while you are doing the
import.

> In this case, what's the
> best command for doing that ?

I can't find the reference in the docs just now, but I
believe it's:
SELECT setval ('sequence_name', new_value);

>
> Thanks
>
> Eric GRIMOIS
> Analyste programmeur
> SEI - CPAM du Val d'Oise
> 01.34.22.24.56
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please
> send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org
> so that your
> message can get through to the mailing list cleanly

__________________________________________________
Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards
http://movies.yahoo.com/

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Dmitry Tkach 2002-03-21 20:49:29 A general database question!
Previous Message Oliver Elphick 2002-03-21 19:01:24 Re: Sequence not updated after a copy ?