FIND YOUR NEXT FEW LINES

The snippet library.

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

10 snippets foundClear filters
SQLiteConstraints & defaults

Apply a default when an insert omits a column

SQLite: A default supplies an omitted value; an explicit NULL still follows the column’s nullability rules.

SQLite✓ Tested
SQLiteConstraints & defaults

Block deletion of a referenced parent

SQLite: The default foreign-key action prevents deletion while a child still refers to the parent.

SQLite✓ Tested
SQLiteConstraints & defaults

Enforce a bounded numeric range

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

SQLite✓ Tested
SQLiteConstraints & defaults

Keep children while clearing a deleted relationship

SQLite: ON DELETE SET NULL requires a nullable foreign-key column.

SQLite✓ Tested
SQLiteConstraints & defaults

Make a pair of columns unique together

SQLite: A composite primary key permits repeated individual values while forbidding a duplicate combination.

SQLite✓ Tested
SQLiteConstraints & defaults

Reference a parent identified by two columns

SQLite: A composite foreign key checks the complete referenced key rather than either column independently.

SQLite✓ Tested
SQLiteConstraints & defaults

Reject a negative quantity with CHECK

SQLite: Combine NOT NULL and CHECK because an unknown NULL check result is normally accepted.

SQLite✓ Tested
SQLiteConstraints & defaults

Reject duplicate business identifiers

SQLite: A UNIQUE constraint protects a business key independently of the primary key.

SQLite✓ Tested
SQLiteConstraints & defaults

Remove dependent rows with a declared cascade

SQLite: ON DELETE CASCADE removes children when their referenced parent is deleted.

SQLite✓ Tested
SQLiteConstraints & defaults

Require a value with NOT NULL

SQLite: Declare required fields at the database boundary, not only in application validation.

SQLite✓ Tested