At 11:13 AM -0700 10/6/05, Antony Sargent wrote:
Alternatively, you might consider making the id_allocator table have
an auto-increment primary key, and then insert null to have sqlite
generate id's for you, and use last_insert_rowid() to find out the
value it generated.
/* Initialize system */
BEGIN;
CREATE TABLE id_allocator(id INTEGER PRIMARY KEY);
COMMIT;
/* Retrieve next id in sequence: */
INSERT INTO id_allocator (id) VALUES (NULL);
SELECT last_insert_rowid(); /* This is the id to use */
I'm inclined to think that this is a bad idea by itself because your
id_allocator table ends up with a large number of records in it, one
per increment, which take up space but don't serve a useful purpose.
Whereas, an updating approach will not take up any more space than
necessary. -- Darren Duncan