GUID in PostgreSQL...

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
burning snow
Posts: 6
Joined: Sun 09 Sep 2007 10:26

GUID in PostgreSQL...

Post by burning snow » Sun 09 Sep 2007 11:00

Hi folks,

Since I'm converting a project from MSSQL to PostgreSQL I don't know how to handle the GUID / uniqueidentifier Fields.

I know that PostgreSQL doesn't have this datatype but what is the best practice for this kind of problem?

Thank you very much in advance.

Alexey
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Mon 10 Sep 2007 08:22

If you need unique identifier of each record, use the following syntax:

Code: Select all

CREATE TABLE tablename
(
  ...
) 
WITH OIDS;
For more information about oids please see PostgreSQL Server documentation.

burning snow
Posts: 6
Joined: Sun 09 Sep 2007 10:26

Post by burning snow » Sun 30 Sep 2007 12:35

It is not possible to use OID for my problem.

Why?

In the PostgreSQL Documentation (http://www.postgresql.org/docs/8.2/inte ... e-oid.html) it says that I can't use it like I use GUID on a MSSQL Database.
The oid type is currently implemented as an unsigned four-byte integer. Therefore, it is not large enough to provide database-wide uniqueness in large databases, or even in large individual tables. So, using a user-created table's OID column as a primary key is discouraged. OIDs are best used only for references to system tables.
Isn't it possible to create a new type for PostgreSQL and use it with CoreLab Data Provider?

Alexey
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Mon 01 Oct 2007 07:16

As far as we know, it is not possible to create new types in PostgreSQL Server.

Post Reply