sqlite-foreign-key-action · shipping · also SQLite ON DELETE action, SQLite ON UPDATE action

SQLite foreign-key action

A SQLite foreign-key action defines the response to deleting or changing a referenced parent key.

Related Observatory article: SQLite foreign-key action on hesela.com

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. [1]

With 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. [3] [4]

Global 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. [2] [4]

Relations

related
SQLite REPLACE, SQLite foreign_key_check, SQLite integrity_check

Citations

  1. SQLite Foreign Key Support: sections 2, 4.2, 4.3 and 6 (accessed 2026-10-21)
  2. SQLite version-3.45.1 fkey.c: fkActionTrigger and SQLITE_DeferFKs (accessed 2026-10-21)
  3. Hesela: REPLACE, foreign-key actions and complete reopened rows (accessed 2026-10-21)
  4. Hesela: 24 matrix cases, four global-deferral controls and two orphan controls (accessed 2026-10-21)
Sources & caveats
  • 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.

JSON: /data/terms/sqlite-foreign-key-action.json

Published by Hesela team · Updated

Report a correction · Editorial standards · Reuse guidance

Cite this page
Hesela team. SQLite foreign-key action. Hesela. 2026-10-21. https://hesela.dev/terms/sqlite-foreign-key-action/