Skip to content

Instantly share code, notes, and snippets.

@aaronpuchert
Created May 11, 2013 17:27
Show Gist options
  • Save aaronpuchert/5560712 to your computer and use it in GitHub Desktop.
Save aaronpuchert/5560712 to your computer and use it in GitHub Desktop.
Alter table in SQLite. This is not possible directly, we need a workaround. This keeps foreign key relations from other tables alive.
CREATE TABLE tab2 (
columns TEXT);
INSERT INTO tab2 (columns) SELECT columns from tab;
DROP TABLE tab;
ALTER TABLE tab2 RENAME TO tab;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment