NextNumbers Tables
From: stu <smcgouga_at_nospam.co.uk>
Date: Fri, 7 Feb 2003 10:24:16 -0000
Message-ID: <b201j4$7mp$1$8302bc10_at_news.demon.co.uk>
Ive heard ppl suggest a next numbers table to generate a unique ID for a surrogate primary key. Something like:
CREATE TABLE STUART.NEXTNUMBERS (TABLENAME VARCHAR (20 ) NOT NULL, NEXTNUMBER BIGINT NOT NULL) They then increment the next number when one is taken. My question is:
Date: Fri, 7 Feb 2003 10:24:16 -0000
Message-ID: <b201j4$7mp$1$8302bc10_at_news.demon.co.uk>
Ive heard ppl suggest a next numbers table to generate a unique ID for a surrogate primary key. Something like:
CREATE TABLE STUART.NEXTNUMBERS (TABLENAME VARCHAR (20 ) NOT NULL, NEXTNUMBER BIGINT NOT NULL) They then increment the next number when one is taken. My question is:
If the number is just a unique meaningless number why not have: CREATE TABLE STUART.NEXTNUMBER (NEXTNUMBER BIGINT NOT NULL) and all tables use the same next number. Just though of one reason as im writing this. This would mean all inserts (even across different tables) would need t be
serialised. This is a pretty good reason not to use this!Any more thoughts on a next numbers table for surrogate keys?
Cheers
Stu
Received on Fri Feb 07 2003 - 11:24:16 CET