good choice!! I don't know anything about MS SQL though - someone else will probably
be able to help you on specific migration issues.
Hoever, on the subject of auto increment: PostgreSQL uses sequence generators. You can
create a sequence generator by using the CREATE SEQUENCE syntax:
eno=# \h create sequence
Command: CREATE SEQUENCE
Description: define a new sequence generator
Syntax:
CREATE [ TEMPORARY | TEMP ] SEQUENCE seqname [ INCREMENT increment ]
[ MINVALUE minvalue ] [ MAXVALUE maxvalue ]
[ START start ] [ CACHE cache ] [ CYCLE ]
OR you can have postgresql create a sequence for you by using the SERIAL datatype:
eno=# create table example ( exp_uid SERIAL PRIMARY KEY );
NOTICE: CREATE TABLE will create implicit sequence 'example_exp_uid_seq' for SERIAL
column 'example.exp_uid'
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'example_pkey' for
table 'example'
CREATE
the nextval('sequence_name) and currval('sequence_name') functions give you the
current and next sequence values (multiuser-safe) e.g.
millerhomes=# select nextval('developments_seq');
nextval
---------
10124
(1 row)
You can find out about a sequence by doing a SELECT:
millerhomes=# SELECT * FROM developments_seq;
sequence_name | last_value | increment_by | max_value | min_value | cache_value |
log_cnt | is_cycled | is_called
------------------+------------+--------------+------------+-----------+-------------+---------+-----------+-----------
developments_seq | 10124 | 1 | 2147483647 | 10000 | 1 |
32 | f | t
(1 row)
See the docs:
http://www.postgresql.org/idocs/index.php?sql-createsequence.html
http://www.postgresql.org/idocs/index.php?functions-sequence.html
by the way pgAdminII is a very good GUI admin tool for postgres, and it has a DB
migration plugin that supports migration from MS SQL. I've never had the need to use
it myself tho ;-)
http://pgadmin.postgresql.org
HTH,
Ben
> -----Original Message-----
> From: jt [mailto:[EMAIL PROTECTED]]
> Sent: 11 September 2002 16:34
> To: CF-Linux
> Subject: RE: snagging the recently created PK of a record in MySQL -
> Help?
>
>
> Hello,
>
> I am moving a DB from MS SQL Server 2000 to PostgreSQL (hooray!!!).
>
> Any tips or tricks to share?
>
> I am especially interested in how to auto-increment ids in
> Postgresql, if
> there are any caveats, and how to transfer the data over
> after the tables
> and such are built.
>
> Thanks,
>
> Josh
>
>
>
______________________________________________________________________
Your ad could be here. Monies from ads go to support these lists and provide more
resources for the community. http://www.fusionauthority.com/ads.cfm
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-linux%40houseoffusion.com/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_linux or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.