Re: Random Unique Integer

Поиск
Список
Период
Сортировка
От Campbell, Lance
Тема Re: Random Unique Integer
Дата
Msg-id A3AC4FA47DC0B1458C3E5396E685E63302395E47@SAB-DC1.sab.uiuc.edu
обсуждение исходный текст
Ответ на Re: Random Unique Integer  (Michael Fuhr <mike@fuhr.org>)
Ответы Re: Random Unique Integer  (Kristo Kaiv <kristo.kaiv@skype.net>)
Список pgsql-sql
I have a web application that is used to create web surveys and web
forms.  Users can create any number of surveys or forms at any time.
The primary key on one of my tables defines the ID for any given form or
survey.  I do NOT want the number sequential.  Since I use the number in
the web URL as a parameter, I don't want people guessing what survey or
form is next.  By creating a very large random number the users cannot
easily guess another form or survey's ID.  This number is not designed
for security but to keep people from being nosey and poking around
easily into someone else's form or survey.

Can a table have a primary key that is randomly generated?

Thanks,

Lance Campbell
Project Manager/Software Architect
Web Services at Public Affairs
University of Illinois
217.333.0382
http://webservices.uiuc.edu
-----Original Message-----
From: Michael Fuhr [mailto:mike@fuhr.org]
Sent: Thursday, June 14, 2007 8:26 AM
To: Campbell, Lance
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] Random Unique Integer

On Thu, Jun 14, 2007 at 08:08:26AM -0500, Campbell, Lance wrote:
> I have a table T1.  It contains a field called F1.  Is there a way for
> me to set the table T1 up such that F1 can be populated with a random
> integer such that F1 is a unique integer?

What problem are you trying to solve?  The solution might depend
on what you're trying to do.

--
Michael Fuhr


В списке pgsql-sql по дате отправления:

Предыдущее
От: "Rodrigo De León"
Дата:
Сообщение: Re: Organization of tables
Следующее
От: Kristo Kaiv
Дата:
Сообщение: Re: Random Unique Integer