In the SQLite FAQ[1] it is mentioned that SQLite does not have full ALTER TABLE support. In a previous question on StackOverflow [2] a trick is mentioned to accomplish table modifications.
What I would like to know is how to keep FOREIGN KEY references as these are moved to the renamed table which is subsequently deleted. Should I do the same trick with each and every table that has a foreign key relationship with the actual table I am modifying?
PRAGMA foreign_keys=OFF
is not enough due to changes of SQLite mainline. You may also needPRAGMA legacy_alter_table=ON
, but there are caveats here. – Teratology