On Tue, 18 Mar 2008 17:51:39 +0100
"A. Kretschmer" <andreas.kretschmer@schollglas.com> wrote:
> am Tue, dem 18.03.2008, um 9:43:01 -0700 mailte chester c young folgendes:
> > > When inserting a record is there a way to have postgres create a
> > > random number for a field such that it is unique?
> >
> > you could use oid
>
> No! No oid, it's deprecated. The solution: use serial.
Not exactly random, is it?
See http://archives.postgresql.org/pgsql-novice/2002-05/msg00198.php
for a possible solution. Read the followups as well. There is an
issue with collisions which will only get worse with time.
I wonder though, what is the purpose of this? I suspect that this is
either a homework problem or you may be attacking some real-world
problem from the wrong angle.
--
D'Arcy J.M. Cain <darcy@druid.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.