Skip to content

Instantly share code, notes, and snippets.

@teepark
Created January 24, 2012 04:48
Show Gist options
  • Save teepark/1667874 to your computer and use it in GitHub Desktop.
Save teepark/1667874 to your computer and use it in GitHub Desktop.
ON DELETE CASCADE
SQLite version 3.7.10 2012-01-16 13:28:40
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table a(id integer primary key);
sqlite> create table b(aid integer references a(id) on delete cascade);
sqlite> insert into a default values;
sqlite> insert into a default values;
sqlite> insert into a default values;
sqlite> select * from a;
1
2
3
sqlite> insert into b (aid) values (2);
sqlite> select * from b;
2
sqlite> delete from a where id=2;
sqlite> select * from b;
2
sqlite> select * from a;
1
3
sqlite> --WTF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment