Re: Generate Random Primary Key
From: R. Paardekam (robin.paardekam_at_tutch.nl)
Date: 06/04/04
- Next message: R. Paardekam: "Re: Generate Random Primary Key"
- Previous message: R. Paardekam: "Re: Generate Random Primary Key"
- In reply to: David Portas: "Re: Generate Random Primary Key"
- Next in thread: Louis Davidson: "Re: Generate Random Primary Key"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 04 Jun 2004 15:06:09 +0200
Thanks for your reply. Dropping the table first is out of the question.
This database contains content of several sites with a total amount of
hits around 40 per minute, all over the globe... That would take to long
i'm afraid.
I now made an extra query to fill the gaps of unused ID's. This works
great, but requires more effort from the database:
SELECT TOP 1 t1.File_Id FROM Files t1 LEFT OUTER JOIN Files t2 ON
(t1.File_Id + 1) = t2.File_Id WHERE (t2.File_Id IS NULL)
I added 1 to the result of this query and I got an unused ID!
Works great!
Thanks anyway!
Robin Paardekam
Tutch Mobile Media
The Netherlands
David Portas wrote:
> If the values exceed the maximum for the column then you can widen the
> column by making it a BIGINT or NUMERIC. If the column has a Primary Key
> constraint then you'll need to drop it first and redeclare it afterwards.
> That should be easier than trying to generate random keys.
>
>
- Next message: R. Paardekam: "Re: Generate Random Primary Key"
- Previous message: R. Paardekam: "Re: Generate Random Primary Key"
- In reply to: David Portas: "Re: Generate Random Primary Key"
- Next in thread: Louis Davidson: "Re: Generate Random Primary Key"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|