Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete data from multiple tables in sqlite?

Tags:

sqlite

I am using sqlite database to store data. I have three tables: Invoice, InvRow, Invdetails.

Relationsip between the tables are:

Invoice.Id = InvRow.InvId
InvRow.Id = Invdetails.RowId 

I need to delete related entries from three tables using a single query. How can I do that? Any help?

like image 307
diana Avatar asked Nov 14 '09 10:11

diana


1 Answers

SQLite prior to version 3.6.19 (2009 Oct 14) does not support foreign key constraints, but you can use triggers to maintain relational integrity.

Starting with 3.6.19, however, SQLite supports proper foreign key constraints with ON [UPDATE|DELETE] CASCADE clauses, that will do what you want.

like image 92
Alex B Avatar answered Sep 18 '22 08:09

Alex B