From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
---|---|
To: | Bernardo de Barros Franco <electric_csf(at)hotmail(dot)com> |
Cc: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Using Random Sequence as Key |
Date: | 2001-04-16 14:42:30 |
Message-ID: | Pine.LNX.4.30.0104161641300.760-100000@peter.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Bernardo de Barros Franco writes:
> But my only question would be, in the example quoted would id be really the
> table index and is it unique?
Making unique *and* random numbers is a pretty complex (and slow) thing to
do in general. Consider redesigning your application.
>
> Thank you
>
> Quoting:
> >Bernardo de Barros Franco writes:
> >
> > > I wanted to index a table by a random key. Exemplifying, when a insert
> >is
> > > made, the id value is automatically filled with a random number between
> > > 10000 and 99999.
> >
> >=> create table test (id int default random() * 89999 + 10000, content
> >text);
> >CREATE
> >=> insert into test (content) values ('hi');
> >INSERT 36163 1
> >=> insert into test (content) values ('there');
> >INSERT 36164 1
> >=> insert into test (content) values ('blah');
> >INSERT 36165 1
> >=> select * from test;
> > id | content
> >-------+---------
> > 61616 | hi
> > 72605 | there
> > 83469 | blah
> >(3 rows)
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
>
--
Peter Eisentraut peter_e(at)gmx(dot)net http://funkturm.homeip.net/~peter
From | Date | Subject | |
---|---|---|---|
Next Message | cbell | 2001-04-16 15:29:51 | Range of Serial values |
Previous Message | Jeff Hoffmann | 2001-04-16 14:18:32 | Re: RTREE on points |