Skip site navigation (1) Skip section navigation (2)

Is a randomized default value primary key possible?

From: April L <april(at)i-netco(dot)com>
To: PgSQL Novice ML <pgsql-novice(at)postgresql(dot)org>
Subject: Is a randomized default value primary key possible?
Date: 2002-05-19 16:10:04
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
After reading about data types, create table, and other search results for
"default" and "random" in the postgres idocs, I haven't found a way to do

Instead of a sequentially auto-incrementing primary key, I would like a
random 16 byte character value (assumedly hex) to be automatically created
as the default value for each new record.

I guess I could just use a large random number, created with the postgres
random() function - however I don't see any way of seeding it, or know if
that is necessary.

The purpose of using a random rather than sequential number is to prevent
people being able to access other's records by guessing. 

Has anyone else encountered this challenge, and do you know of a way to
generate a random default value for the primary key?

Thank you,

- April

In response to


pgsql-novice by date

Next:From: Tom LaneDate: 2002-05-19 16:45:59
Subject: Re: Forgotten the master password of db
Previous:From: Susan EvansDate: 2002-05-19 14:04:14
Subject: SSL Error

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group