Default UUID in Postgres

From: "Swaminathan Saikumar" <swami(at)giveexam(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Default UUID in Postgres
Date: 2008-07-09 23:32:11
Message-ID: 82692d4a0807091632p49febb89vefae7416e1534b53@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I created a Postgres table with a UUID. I want the UUID to be populated by
default.

Sample table:
CREATE TABLE "t"
(
token uuid NOT NULL,
CONSTRAINT unique_token UNIQUE (token)
);

I tried out this post:
http://archives.postgresql.org/pgsql-general/2006-08/msg01452.php
CREATE TABLE t (id UUID DEFAULT 'uuid(4)' PRIMARY KEY);

and got an error that uuid(4) is undefined.

I then tried out:
http://www.postgresql.org/docs/8.3/static/uuid-ossp.html
using uuid_generate_v4() for the default.

That didn't work as well.

Can anyone help please?

Thanks!

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Iv Ray 2008-07-09 23:35:09 Re: MSSQL to PostgreSQL
Previous Message Gwyneth Morrison 2008-07-09 22:43:54 Re: MSSQL to PostgreSQL