I have a SQLite table that looks like this:
CREATE TABLE myTable (
_id integer primary key autoincrement,
...
... /* some useful fields */
...
parent integer,
FOREIGN KEY (parent) REFERENCES myTable (_id)
);
Some of the entries in myTable have a parent, others don't. Business logic ensures that there are no "circles". I'm using PRAGMA foreign_keys = ON
, so that foreign key violations are detected.
Question: If I want to delete the whole table, is it enough to execute DELETE FROM myTable
? Or do I need to delete the "leaves" first, then their parents, etc., all the way up to avoid foreign key violations?
I've tested it and using just DELETE FROM myTable
seems to work. However, I want to know whether this is just a coincidence or something I can rely upon (i.e. documented and expected behaviour).
EDIT: I don't have ON DELETE CASCADE
enabled, and this is on purpose.