The auto increment just adds 1 to the highest value in the id column, so you if you create a table with

   create table db(id INTEGER PRIMARY KEY, value TEXT)

your sequence of inserts will result in

1, 'first'
2, 'second'
500, 'third'
501, 'fourth'

Martin

----- Original Message ----- From: <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Tuesday, April 11, 2006 2:38 PM
Subject: [sqlite] Unique ids over several databases or auto_increment primary or id range.


Hi, i have several databases with same structure on several hosts, and
want them to generate globaly unique ids.
So can I add row to table with explicit id and without modyfing rowid sequence?
eg
insert into db (value) values ( 'first' ) ;
insert into db (value) values ( 'second' ) ;
insert into db (id, value) values ( 500, 'third' )    -- EXPLICIT;
insert into db (value) values ( 'ffourth' ) ;

woud give:
1, first
2, second
500, third
3, fourth

I am using different processes and threads accesing same db,
autocommit, 0-isolation so simply updating SQLITE_SEQUENCE wont do.

Marek Pułczyński


Reply via email to