Re: Sequence not updated after a copy ?

From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: GRIMOIS Eric <eric(dot)grimois(at)cpam-cergypontoise(dot)cnamts(dot)fr>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Sequence not updated after a copy ?
Date: 2002-03-21 19:01:24
Message-ID: 1016737285.21170.128.camel@linda
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thu, 2002-03-21 at 17:21, GRIMOIS Eric wrote:
> Hi All
>
> Does 'COPY table FROM...' command update the last_value field of the
> sequence(s) related to the table ?

No

> Is a setval( ) function required after completion ? In this case, what's the
> best command for doing that ?

SELECT setval('sequence_name',
(SELECT MAX(column_name)
FROM table_name)
);

--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C

"Thy word have I hid in mine heart, that I might not
sin against thee." Psalms 119:11

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Jeff Eckermann 2002-03-21 20:34:13 Re: Sequence not updated after a copy ?
Previous Message GRIMOIS Eric 2002-03-21 17:21:50 Sequence not updated after a copy ?