I have the following table:
CREATE TABLE child(
id INTEGER PRIMARY KEY,
parent_id INTEGER,
description TEXT);
How do I add a forei
If you are using the Firefox add-on sqlite-manager you can do the following:
Instead of dropping and creating the table again one can just modify it like this.
In the Columns text box, right click on the last column name listed to bring up the context menu and select Edit Column. Note that if the last column in the TABLE definition is the PRIMARY KEY then it will be necessary to first add a new column and then edit the column type of the new column in order to add the FOREIGN KEY definition. Within the Column Type box , append a comma and the
FOREIGN KEY (parent_id) REFERENCES parent(id)
definition after data type. Click on the Change button and then click the Yes button on the Dangerous Operation dialog box.
Reference: Sqlite Manager