---
source: https://iinventedlight.com/library/notes/sqlite-foreign-keys.md
title: "SQLite foreign keys are off by default"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Public domain (sqlite.org); prose restates cited source lines"
attribution: "Summary by iinventedlight (AI-assisted). Sources: SQLite (sqlite.org), SQLite Foreign Key Support, Public domain (sqlite.org); SQLite (sqlite.org), CREATE TABLE, Public domain (sqlite.org)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-04
status: published
checked_on: 2026-11-04
as_of: 2026-11-04
confidence: medium
untested: "No code was run for this note; only the fetched documentation pages were read."
category: coding-references
topic_area: "code-ai-eng: SQLite"
tags: sqlite, foreign-keys, constraints
sources:
  - id: S1
    title: "SQLite Foreign Key Support"
    publisher: SQLite (sqlite.org)
    url: https://www.sqlite.org/foreignkeys.html
    accessed: 2026-11-04
    license: "Public domain (sqlite.org)"
  - id: S2
    title: "CREATE TABLE"
    publisher: SQLite (sqlite.org)
    url: https://www.sqlite.org/lang_createtable.html
    accessed: 2026-11-04
    license: "Public domain (sqlite.org)"
---
# SQLite foreign keys are off by default

## Short answer
SQLite supports foreign key constraints, but enforcement is disabled by default.

```sql
PRAGMA foreign_keys = ON;
CREATE TABLE track (
  id INTEGER PRIMARY KEY,
  artist_id INTEGER REFERENCES artist(id) ON DELETE CASCADE
);
```

## Key points
- Without the pragma, constraints are not enforced. [S1]
- `INTEGER PRIMARY KEY` columns alias the rowid. [S2]

## Claims
- id: C1
  claim: Foreign key constraints are disabled by default in SQLite.
  source: S1
  evidence: "SQLite (it is disabled by default)."
- id: C2
  claim: Enable enforcement with PRAGMA foreign_keys = ON.
  source: S1
  evidence: "sqlite> PRAGMA foreign_keys = ON;"
- id: C3
  claim: CREATE TABLE creates a new table in an SQLite database.
  source: S2
  evidence: "command is used to create a new table in an SQLite"
- id: C4
  claim: The declared type of each column is part of CREATE TABLE.
  source: S2
  evidence: "The declared type of each column in the table."

## Sources
- [S1] SQLite Foreign Key Support. SQLite (sqlite.org). https://www.sqlite.org/foreignkeys.html . License: Public domain (sqlite.org). Accessed 2026-11-04.
- [S2] CREATE TABLE. SQLite (sqlite.org). https://www.sqlite.org/lang_createtable.html . License: Public domain (sqlite.org). Accessed 2026-11-04.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).
