Reputation: 18289
I would like to start different tables off at different values for their primary keys during testing to verify I don't have any bugs in my code. Is this possible in Sqlite?
Upvotes: 1
Views: 521
Reputation: 180060
As documented, the last value of an AUTOINCREMENT column is stored in the internal sqlite_sequence table, where it can be changed.
Upvotes: 3
Reputation: 95572
Yes, you can do that.
The simplest way is probably just to insert a row, and specify the the number. If I wanted to start with 1000, I might do something like this.
sqlite> create table test (test_id integer primary key, s char(1)); sqlite> insert into test values (999, 'a'); sqlite> insert into test (s) values ('b'); sqlite> select * from test; 999|a 1000|b
After you've inserted the "first" row (test_id is 1000), you can delete the "seed" row (test_id is 999).
Upvotes: 0