I've got a table in SQLite
create table table_dishes (_id integer primary key autoincrement,
title text,
price real,
weight real,
description text,
position integer);
How to make field "position integer" autoincrement?
I've got a table in SQLite
create table table_dishes (_id integer primary key autoincrement,
title text,
price real,
weight real,
description text,
position integer);
How to make field "position integer" autoincrement?
There is as such no autoincrement feature but they have added ROWID which is added automatically. So the integer primary key which you will create for your table will point to this ROWID
.
Also from the SQLITE docs:
A column declared INTEGER PRIMARY KEY will autoincrement.
Per the SQLite documentation here,
Short answer: A column declared INTEGER PRIMARY KEY will autoincrement
insert value should be like : (SELECT IFNULL(MAX(position), 0) + 1 FROM table_dishes)
for that column, every time you insert a new row into table_dishes
table, if you decide to keep position column as non-primary key