EXCLUDE CONSTRAINT
EXCLUDE CONSTRAINT is a SQL statement in the Constraints category. PostgreSQL-only: ensures no two rows have overlapping values (e.g., no overlapping time ranges). The syntax is CREATE TABLE table (...) CONSTRAINT name EXCLUDE USING gist (column WITH =);. It returns exclusion constraint. A typical example: CREATE TABLE meetings ( room_id INT, during TSRANGE, EXCLUDE USING GIST (room_id WITH =, during WITH &&) ); -- Prevents double-booking the same room -- && means overlap operator for ranges A close relative is PRIMARY KEY, which a column or set of columns that uniquely identifies each row. Only one PK per table. Automatically creates a unique index. A close relative is FOREIGN KEY, which ensures referential integrity: values in this column must exist in the referenced parent table. A close relative is UNIQUE, which ensures all values in a column (or combination) are unique across the table. Allows NULLs (multiple NULLs allowed).