I use the following query, which solves the problem when sqlite_sequence has no record for the table (i.e. the first record has not yet been added to the table), otherwise it updates the sequence.
BEGIN TRANSACTION; UPDATE sqlite_sequence SET seq = <n> WHERE name = '<table>'; INSERT INTO sqlite_sequence (name,seq) SELECT '<table>', <n> WHERE NOT EXISTS (SELECT changes() AS change FROM sqlite_sequence WHERE change <> 0); COMMIT;
iTech Oct 13 '14 at 3:32 2014-10-13 03:32
source share