Page 1 of 1

Primary Keys

Posted: Thu Jan 09, 2003 8:14 pm
by smoky989
I'd like to have my primary keys be random numbers between 1000 and 9999. Is there any way to do that? This is for mysql by the way. Thaanks in advance.

Posted: Thu Jan 09, 2003 10:14 pm
by fractalvibes
Perhaps just an autonumber primary key could achieve the same effect.
If need be, start it at 1000. If you want to randomly grab a row, just use a randmizing function. Otherwise define the PK as an integer and generate the random key yourself, and have code to do some chaining of values in case of a key collision. Depends upon your needs and intentions.....

Phil J.