I have a table where I need to have a _id column which is incremented. However I cannot use autoincrement due to the table having 3 primary keys. This is in SQLite, btw. The table is already populated with data and therefore I cannot just recreate the table.
Is there a way to insert values from 1 to 148 in the _id column?
We’ve already tried something like this:
UPDATE table1
SET _id = (SELECT _id FROM table2)
table2 is a temp table which contains the values from 1 to 148. However this just updates all _id values to ‘1’..
Any suggestions on how to solve this?
Not certain I understand. But let me try.
of three columns.
not an automatically incremented
integer.
into table1._id.
In SQLite, if either of the other two columns in the primary key are defined as “NOT NULL”, then you can’t do that. You have to insert values for all the “NOT NULL” components of the primary key at the same time. But if they’re nullable, you can insert values into table1._id. Just
This will insert new rows into table1 with null values for all columns except _id.