{
  "status": "shipping",
  "advantages": [],
  "limitations": [],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-10-21",
  "slug": "sqlite-foreign-key-action",
  "term": "SQLite foreign-key action",
  "aliases": [
    "SQLite ON DELETE action",
    "SQLite ON UPDATE action"
  ],
  "definition": "A SQLite foreign-key action defines the response to deleting or changing a referenced parent key.",
  "note": "Actions include NO ACTION, RESTRICT, CASCADE, SET NULL and SET DEFAULT. Their execution is not disabled by recursive_triggers. Enforcement must be enabled separately on the connection. [foreign-keys]\n\nWith schema-level DEFERRABLE INITIALLY DEFERRED and defer_foreign_keys off, the measured REPLACE was rejected by RESTRICT but committed under NO ACTION. CASCADE removed the children even though the parent key was reinserted. [experiment] [data]\n\nGlobal PRAGMA deferral is a separate setting. Four additional SQLite 3.45.1 controls with defer_foreign_keys on allowed that RESTRICT replacement and retained the children. The pinned implementation skips the RESTRICT action program under this flag; do not generalize the schema-level rule to every connection setting. [source] [data]",
  "related": [
    "sqlite-replace",
    "sqlite-foreign-key-check",
    "sqlite-integrity-check"
  ],
  "citations": [
    {
      "id": "foreign-keys",
      "title": "SQLite Foreign Key Support: sections 2, 4.2, 4.3 and 6",
      "url": "https://sqlite.org/foreignkeys.html",
      "accessed": "2026-10-21"
    },
    {
      "id": "source",
      "title": "SQLite version-3.45.1 fkey.c: fkActionTrigger and SQLITE_DeferFKs",
      "url": "https://github.com/sqlite/sqlite/blob/version-3.45.1/src/fkey.c#L1165-L1167",
      "accessed": "2026-10-21"
    },
    {
      "id": "experiment",
      "title": "Hesela: REPLACE, foreign-key actions and complete reopened rows",
      "url": "https://hesela.com/analyses/sqlite-index-runtime-dependencies/#replace-foreign-keys",
      "accessed": "2026-10-21"
    },
    {
      "id": "data",
      "title": "Hesela: 24 matrix cases, four global-deferral controls and two orphan controls",
      "url": "https://hesela.dev/research/sqlite-replace-fk/results.json",
      "accessed": "2026-10-21"
    }
  ],
  "provenance": [
    "24 designed cases plus four global-deferral controls, SQLite 3.45.1. Deferral controls are observations of the recorded build, not a recommendation to bypass deletion restrictions."
  ]
}
