typestar

Turning integrity on in SQL

SQLite only enforces foreign keys when you ask it to, once per connection.

PRAGMA foreign_keys = ON;

PRAGMA foreign_key_list('orders');

PRAGMA foreign_key_check;

PRAGMA integrity_check;

PRAGMA table_info('orders');

How it works

  1. PRAGMA foreign_keys = ON is per connection and off by default.
  2. foreign_key_check lists rows that already point at nothing.
  3. integrity_check verifies the file's own structure.

Keywords and builtins used here

The run, in numbers

Lines
9
Characters to type
143
Tokens
23
Three-star pace
90 tpm

At the three-star pace of 90 tokens a minute, this run takes about 15 seconds.

Type this snippet

Step 2 of 2 in Referential integrity, step 7 of 16 in Schema & constraints.

← Previous Next →