Re: Sequence not updated after a copy ? - Mailing list pgsql-sql

From Oliver Elphick
Subject Re: Sequence not updated after a copy ?
Date
Msg-id 1016737285.21170.128.camel@linda
Whole thread Raw
In response to Sequence not updated after a copy ?  ("GRIMOIS Eric" <eric.grimois@cpam-cergypontoise.cnamts.fr>)
List 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.Elphick@lfix.co.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 



pgsql-sql by date:

Previous
From: "GRIMOIS Eric"
Date:
Subject: Sequence not updated after a copy ?
Next
From: Dmitry Tkach
Date:
Subject: A general database question!