constraint

EXCLUDE

PostgreSQL exclusion constraints prevent two rows from satisfying all specified operator comparisons simultaneously. A range-overlap rule can prevent overlapping bookings; adjacent half-open ranges are allowed. SQLite has no equivalent EXCLUDE table constraint. Target: PostgreSQL 17; focused syntax.

Formal Syntax & Structure

sql syntaxsql
EXCLUDE USING gist (slot WITH &&)

Working Example

Example Snippetsql
CREATE TABLE bookings(slot int4range NOT NULL, EXCLUDE USING gist (slot WITH &&));INSERT INTO bookings VALUES ('[1,3)'),('[3,5)');INSERT INTO bookings VALUES ('[2,4)');
SQL Reference