pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
General question regarding sequences (Serial columns)
2+ messages / 1 participants
[nested] [flat]

* General question regarding sequences (Serial columns)
@ 2006-06-15 17:20  Benjamin Krajmalnik <kraj@illumen.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Benjamin Krajmalnik @ 2006-06-15 17:20 UTC (permalink / raw)
  To: pgsql-admin

I am in the process of writing a migration utility to move data from a
SQL Server to PostgreSQL.  The original schema contains identity fields.
When converting the schema, I have 2 option - either make them serial
(or bigserisl) columns, with the associated automatic constraint, or
declaring the associated sequences separately and invoking the
generators in code.

If I were to use the former (use Serial/BigSerial), is there a command
which I can issue to keep PostgreSQL from using the sequence, and
therefore copying over the original identity field value?  Something
equivalent to SQL Server's "SET IDENTITY_INSERT" command?




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

* Re: General question regarding sequences (Serial columns)
@ 2006-06-15 17:31  Benjamin Krajmalnik <kraj@illumen.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Benjamin Krajmalnik @ 2006-06-15 17:31 UTC (permalink / raw)
  To: Juan Miguel Paredes <juan.paredes@gmail.com>; pgsql-admin

Thanks.  I just looked at the definition and see it is a default value,
so I should be safe just pumping the data over.
On completion of the import I plan to reseed he sequence generator.


-----Original Message-----
From: Juan Miguel Paredes [mailto:juan.paredes@gmail.com] 
Sent: Thursday, June 15, 2006 11:28 AM
To: Benjamin Krajmalnik
Subject: Re: [ADMIN] General question regarding sequences (Serial
columns)

> If I were to use the former (use Serial/BigSerial), is there a command
> which I can issue to keep PostgreSQL from using the sequence, and
> therefore copying over the original identity field value?  Something
> equivalent to SQL Server's "SET IDENTITY_INSERT" command?

"Serial" declares your column being an integer type and provides a
default value (the next value from the sequence).  If you DO provide a
value for your id column, PostgreSQL won't use the sequence.  However,
be careful to keep in sync your sequence with the values in your
table, to avoid collissions (ALTER SEQUENCE can help)

Regards.



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


end of thread, other threads:[~2006-06-15 17:31 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-06-15 17:20 General question regarding sequences (Serial columns) Benjamin Krajmalnik <kraj@illumen.com>
2006-06-15 17:31 Re: General question regarding sequences (Serial columns) Benjamin Krajmalnik <kraj@illumen.com>

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