Name
foreign_keys — Enable foreign key constraints
Common Usage
PRAGMA foreign_keys;
PRAGMA foreign_keys = switch;Description
The foreign_keys pragma controls the enforcement of
foreign key constraints in all of the attached databases. If set
to off, foreign key constraints are ignored. The default value
is off.
For many years, SQLite would parse foreign key constraints, but was unable to enforce them. When native support for foreign key constraints was finally added to the SQLite core, enforcement was off by default to avoid any backwards compatibility issues.
This default value may change in future releases. To avoid problems, it is recommended that an application explicitly set the pragma one way or the other.
This pragma cannot be set when there is an active transaction in progress.
See Also
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access