Primary Keys
Moderator: General Moderators
Primary Keys
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.
-
fractalvibes
- Forum Contributor
- Posts: 335
- Joined: Thu Sep 26, 2002 6:14 pm
- Location: Waco, Texas
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.
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.