Dev Helpers

SQL / Constraints and defaults

Use a default field value

Dev Helpers · January 31, 2026

A column default applies when an insert omits that column. Supplying an explicit NULL is a separate operation.

Worked example

CREATE TABLE notes(title TEXT DEFAULT 'Draft');
INSERT INTO notes DEFAULT VALUES;
SELECT title FROM notes;

Result

[
  {
    "title": "Draft"
  }
]

Implementation notes

A default does not retroactively change existing rows. Decide whether a migration also needs to backfill values already stored.

Try it yourself

Insert one row each way and inspect the stored values.

Open the SQL example →

Editorial date January 31, 2026 · Published December 6, 2026

Related articles

Compare two literal lists

Set operations compare rows under SQL's rules for duplicates. Check whether the result represents membership or the number of occurrences.

Count jobs per active day

Grouping timestamps by day produces counts only for days present in the data. A continuous chart may need a calendar series as well.