Re: Importing Microsoft Sql Server 2000 - Mailing list pgsql-novice

From Andrew Hammond
Subject Re: Importing Microsoft Sql Server 2000
Date
Msg-id 4187DCD3.6010108@ca.afilias.info
Whole thread Raw
In response to Re: Importing Microsoft Sql Server 2000  (Aleksandar Dezelin <dezelin32@fastmail.fm>)
List pgsql-novice
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Aleksandar Dezelin wrote:
| Ryan Riehle wrote:
|
|> I have some experience with that so feel free to contact me if you run
|> into any snags.  Hopefully you are on your way by now.
|>
|>  -RYAN
|>
|>
|>
|>
| I have a problem with converting a MSSQL database to PostgreSQL. I saw
| in the data types list that PostgreSQL doesn't support Guid
| (uniqueidentifier) as a built-in type. So I'm just currious what data
| type to use instead of MSSQL uniqueidentifier?

Well, you've got some choices. If the behaviour you want is

"a guaranteed unique, auto-incrementing integer value"

Then the easiest way to do this is to use the SERIAL type. So for
example, you could write this:

CREATE TABLE foo (
~    foo_id SERIAL PRIMARY KEY,
~    ...
);

Which is like

CREATE SEQUENCE foo_id_seq;
CREATE TABLE foo (
~    foo_id int4 UNIQUE NOT NULL DEFAULT (nextval('foo_id_seq')),
~    ...
~    PRIMARY KEY (foo_id)
);

Actually the PRIMARY KEY constraint implies UNIQUE (and I think NOT NULL
too), but I figured it's good to be clear.

- --
Andrew Hammond    416-673-4138    ahammond@ca.afilias.info
Database Administrator, Afilias Canada Corp.
CB83 2838 4B67 D40F D086 3568 81FC E7E5 27AF 4A9A
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQFBh9zSgfzn5SevSpoRAkwqAJwMfwy/H56FkxB7S4VqVgjizX+FjwCfWxhu
aEfaymQy4iYfiTkm0e7oF1M=
=SxtF
-----END PGP SIGNATURE-----

pgsql-novice by date:

Previous
From: Andrew Hammond
Date:
Subject: Re: [SQL] Log
Next
From: Jeff Eckermann
Date:
Subject: Re: Importing Microsoft Sql Server 2000