Re: function for creating random id - Mailing list pgsql-general

From Bruno Wolff III
Subject Re: function for creating random id
Date
Msg-id 20020415184949.GA10684@wolff.to
Whole thread Raw
In response to function for creating random id  (Moritz Sinn <moritz@freesources.org>)
Responses Re: function for creating random id  (Moritz Sinn <moritz@freesources.org>)
List pgsql-general
On Mon, Apr 15, 2002 at 05:51:53PM +0200,
  Moritz Sinn <moritz@freesources.org> wrote:
> hi,
>
> i've got a table called "user". every user should have a userid, which
> is the primary key. this userid is a random number with up to 6 digits.
>
> but now the problem is that the id which is returned by getuid() could
> already be in use.
> so what is the best method to realize that?

Do the IDs really need to be random? Is the order that users were created
in really secret information?

If they don't, you can use a sequence to allocate IDs.

pgsql-general by date:

Previous
From: Neil Conway
Date:
Subject: Re: Alter/update large tables - VERRRY annoying behaviour!
Next
From: Tom Lane
Date:
Subject: Re: psql and passwords