pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Sequence not updated after a copy ?
4+ messages / 4 participants
[nested] [flat]

* Sequence not updated after a copy ?
@ 2002-03-21 17:21  GRIMOIS Eric <eric.grimois@cpam-cergypontoise.cnamts.fr>
  0 siblings, 2 replies; 4+ messages in thread

From: GRIMOIS Eric @ 2002-03-21 17:21 UTC (permalink / raw)
  To: pgsql-sql

Hi All

Does 'COPY table FROM...' command update the last_value field of the
sequence(s) related to the table ?
Is a setval( ) function required after completion ? In this case, what's the
best command for doing that ?

Thanks

Eric GRIMOIS
Analyste programmeur
SEI - CPAM du Val d'Oise
01.34.22.24.56




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Sequence not updated after a copy ?
@ 2002-03-21 19:01  Oliver Elphick <olly@lfix.co.uk>
  parent: GRIMOIS Eric <eric.grimois@cpam-cergypontoise.cnamts.fr>
  1 sibling, 0 replies; 4+ messages in thread

From: Oliver Elphick @ 2002-03-21 19:01 UTC (permalink / raw)
  To: GRIMOIS Eric <eric.grimois@cpam-cergypontoise.cnamts.fr>; +Cc: 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 




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Sequence not updated after a copy ?
@ 2002-03-21 20:34  Jeff Eckermann <jeff_eckermann@yahoo.com>
  parent: GRIMOIS Eric <eric.grimois@cpam-cergypontoise.cnamts.fr>
  1 sibling, 1 reply; 4+ messages in thread

From: Jeff Eckermann @ 2002-03-21 20:34 UTC (permalink / raw)
  To: GRIMOIS Eric <eric.grimois@cpam-cergypontoise.cnamts.fr>; pgsql-sql


--- GRIMOIS Eric
<eric.grimois@cpam-cergypontoise.cnamts.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@postgresql.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/



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Sequence not updated after a copy ?
@ 2002-03-22 01:59  Christopher Kings-Lynne <chriskl@familyhealth.com.au>
  parent: Jeff Eckermann <jeff_eckermann@yahoo.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Christopher Kings-Lynne @ 2002-03-22 01:59 UTC (permalink / raw)
  To: Jeff Eckermann <jeff_eckermann@yahoo.com>; GRIMOIS Eric <eric.grimois@cpam-cergypontoise.cnamts.fr>; pgsql-sql

Try this:

http://www.brasileiro.net/postgres/cookbook/view-one-recipe.adp?recipe_id=17
53

Chris




^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2002-03-22 01:59 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-03-21 17:21 Sequence not updated after a copy ? GRIMOIS Eric <eric.grimois@cpam-cergypontoise.cnamts.fr>
2002-03-21 19:01 ` Oliver Elphick <olly@lfix.co.uk>
2002-03-21 20:34 ` Jeff Eckermann <jeff_eckermann@yahoo.com>
2002-03-22 01:59   ` Christopher Kings-Lynne <chriskl@familyhealth.com.au>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox