FIND YOUR NEXT FEW LINES

The snippet library.

Small, practical examples. Search by task or narrow things down below.

125 snippets foundClear filters
SQLiteTables & writes

Enable and use foreign keys

Turn on relationship enforcement for the connection.

foreign keys✓ Tested
SQLiteConstraints & defaults

Enforce a bounded numeric range

SQLite: A named CHECK constraint keeps numeric values inside an inclusive interval.

SQLite✓ Tested
SQLiteSchema design & transactions

Enforce a relationship between two columns

SQLite: A row-level CHECK can require a start value to be no greater than an end value.

SQLite✓ Tested
SQLiteSchema design & transactions

Enforce uniqueness with a dedicated index

SQLite: A unique index rejects a duplicate combination independently of query plans.

SQLite✓ Tested
SQLiteJSON data

Expand a JSON array into rows

Iterate array elements using a table-valued function.

json_each✓ Tested
SQLiteSchema design & transactions

Expose a reusable filtered view

SQLite: A view stores a query definition rather than a snapshot of its rows.

SQLite✓ Tested
SQLiteJSON data

Extract a JSON field

Read a scalar value from JSON text.

json_extract✓ Tested
SQLiteQueries & text

Extract part of a string

Use one-based positions with substr.

substr✓ Tested
SQLiteGetting Started

Filter by a numeric comparison

SQLite: Keep rows whose quantity exceeds a chosen threshold.

SQLite✓ Tested
SQLiteGetting Started

Filter groups after aggregation

SQLite: Use HAVING to test a group’s calculated total.

SQLite✓ Tested
SQLiteReporting & grouped calculations

Filter rows before grouping

SQLite: WHERE limits the rows contributing to the aggregate; it differs from filtering completed groups with HAVING.

SQLite✓ Tested
SQLiteGetting Started

Find missing values with IS NULL

SQLite: Use IS NULL rather than equality to test for missing data.

SQLite✓ Tested