Hi Everyone,

I would like to be able to change the step size of an AUTOINCREMENT rowid,
so that it is incremented by some integer other than 1. The purpose is for
database replication, for which I need rows of a table in two different
databases to have non-overlapping rowid ranges. I have tried to do this with
a trigger which changes sqlite_sequence system table after each update as
shown below, but it did not work:


CREATE TABLE test (id integer primary key autoincrement, stuff text);
INSERT into test (stuff) values ('one');

SELECT * from sqlite_sequence;
name        seq       
----------  ----------
test        1         

CREATE TRIGGER test_trigger AFTER INSERT ON test FOR EACH ROW BEGIN update
sqlite_sequence set seq=seq+1 where name='test'; END;

INSERT into test (stuff) values ('two');
INSERT into test (stuff) values ('three');

SELECT * from test;
id          stuff     
----------  ----------
1           one       
2           two       
3           three  

SELECT * from sqlite_sequence;
name        seq       
----------  ----------
test        3     



I've also tried to set an update trigger on sqlite_sequence table, but got
an error: "SQL error: cannot create trigger on system table". Could you
please tell me why above doesn't work? Also, if anyone has any suggestions
on how to change the step size of an AUTOINCREMENT rowid in a table, I would
very much appreciate to hear your opinion.

Thanks in advance.
-- 
View this message in context: 
http://www.nabble.com/Autoincrement-step-size-tf2925868.html#a8179183
Sent from the SQLite mailing list archive at Nabble.com.


-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to