From: | Andrew Hammond <ahammond(at)ca(dot)afilias(dot)info> |
---|---|
To: | Aleksandar Dezelin <dezelin32(at)fastmail(dot)fm> |
Cc: | pgsql-novice <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: Importing Microsoft Sql Server 2000 |
Date: | 2004-11-02 19:15:31 |
Message-ID: | 4187DCD3.6010108@ca.afilias.info |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)ca(dot)afilias(dot)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-----
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Eckermann | 2004-11-02 20:26:50 | Re: Importing Microsoft Sql Server 2000 |
Previous Message | Andrew Hammond | 2004-11-02 18:56:12 | Re: [SQL] Log |