Primary Keys

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
smoky989
Forum Commoner
Posts: 41
Joined: Mon Sep 02, 2002 1:14 pm

Primary Keys

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

Post 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.
Post Reply