1

I need to create a table in SQLite (for android) where the AutoIncrement value starts from a specific value and not form 1, for example 100.

Here is an example of the create statement: CREATE TABLE IF NOT EXISTS ESTADO (ID_ESTADO INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,DESCRIPCION varchar(45) DEFAULT NULL);

Thanks!

2 Answers2

0

When inserting first record, add the start value for the auto increment field. then all new records will start from that value.

sudanix
  • 515
  • 3
  • 9
0

You can take a look at the sqlite documentation.

SQLite keeps track of the largest ROWID that a table has ever held using an internal table named "sqlite_sequence". The sqlite_sequence table is created and initialized automatically whenever a normal table that contains an AUTOINCREMENT column is created. The content of the sqlite_sequence table can be modified using ordinary UPDATE, INSERT, and DELETE statements. But making modifications to this table will likely perturb the AUTOINCREMENT key generation algorithm. Make sure you know what you are doing before you undertake such changes.

You can update the sqlite_sequence table to your table autoincrement starts at 100 for example.

Community
  • 1
  • 1
Giacomoni
  • 1,468
  • 13
  • 18