I have the following table:
CREATE TABLE child(
id INTEGER PRIMARY KEY,
parent_id INTEGER,
description TEXT);
How do I add a forei
Basically you cannot but you can bypass the situation.
The correct way to add the foreign key constraint to an existing table is the following command.
db.execSQL("alter table child add column newCol integer REFERENCES parent(parent_Id)");
Then copy the parent_Id data to the newCol and then delete the Parent_Id column. Hence, no need for temporary table.