Re: [SQL] Using Random Sequence as Key

2001-04-16 Thread Bernardo de Barros Franco
Thank you it was pretty much something like that. I need to make a sale table but the sale code is a random number. Since it is going to be used in all queries and it is unique, it might as well be my table key (index). I could make a index and other field to be the sale code but then I would h

Re: [SQL] Using Random Sequence as Key

2001-04-16 Thread Roberto Mello
On Sun, Apr 15, 2001 at 10:58:40PM -0300, Bernardo de Barros Franco wrote: > 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 > 1 and 9. I'm pretty new in pgsql so I could use a howto or

Re: [SQL] Using Random Sequence as Key

2001-04-16 Thread Peter Eisentraut
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 > > Quo

Re: [SQL] Using Random Sequence as Key

2001-04-16 Thread Peter Eisentraut
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 > 1 and 9. => create table test (id int default random() * 8 + 1, content text); CREATE => inser