Brandon Young
Brandon Young

Reputation: 79

SQLite: Autoincrementing an Id to increase by 2

I was previously using SQL CE and have decided to move over to SQLite.

With that being said, SQL CE allowed me to auto increment an id by 2.

Is this is possible with SQLite?

Upvotes: 1

Views: 39

Answers (1)

CL.
CL.

Reputation: 180060

SQLite has no mechanism to do this automatically.

But you can calculate the new ID manually while inserting:

INSERT INTO MyTable(ID, Name, Number)
VALUES((SELECT MAX(ID) + 2 FROM MyTable),
       'me', 42);

Upvotes: 1

Related Questions