user740521
user740521

Reputation: 1204

SQLITE foreign key delete not working

I have done

PRAGMA foreign_keys=ON;

and it's still not working. Tables:

tbl_one {
  user_id integer PRIMARY KEY NOT NULL,
  description text,
  FOREIGN KEY (user_id) REFERENCES tbl_two (id) ON DELETE CASCADE
}

tbl_two {
  id integer PRIMARY KEY NOT NULL
}

Now deleting a user from tbl_two should delete the entry in tbl_one but it does not sqlite version is 3.5.6.

Upvotes: 1

Views: 567

Answers (1)

Benoit
Benoit

Reputation: 79243

Foreign key constraint enforcement was added to SQLite 3.6.19 (read first paragraph of section 2). Prior to that version, the statements could be parsed and compile, but with no effect.

Upvotes: 1

Related Questions