Skip to main content

1. UNIQUE NULLS NOT DISTINCT (PG15)

Postgres treats NULL as distinct from NULL. UNIQUE (email) will store two rows with email IS NULL. UNIQUE NULLS NOT DISTINCT (email) makes those two rows collide — the uniqueness most people think they already have.

2. WITHOUT OVERLAPS / PERIOD (PG18)

One id, several versions, those versions cannot overlap in time.
The child period has to sit inside a parent version.

3. BEGIN ATOMIC (PG14)

Most functions are a dollar-quoted string. The SQL-standard form is not:
No $$ quotes. The parser sees real statements.

4. CHECK (false) NO INHERIT

My personal favorite, since it feels like applying design patterns to SQL. Classic pattern on an INHERITS parent: reject inserts on the parent, let children accept them.
Without NO INHERIT, every child inherits the always-false check and nothing can insert.

5. CREATE CONSTRAINT TRIGGER

A trigger that behaves like a constraint: it can be DEFERRABLE INITIALLY DEFERRED and fire at commit. Regular CREATE TRIGGER cannot.
Fire after the rest of the transaction — or not at all if the row is changed back. Postgres has a lot of syntax. What’s your secret tip?