A generalization of UNIQUE constraints that uses arbitrary operators — most commonly used to prevent overlapping date/time ranges or spatial objects.
PostgreSQL constraint that ensures no two rows overlap in a specified way, using exclusion operators (e.g., cannot overlap in time). Implemented with a GiST index. Essential for scheduling systems where double-booking must be prevented.
| Database System | Support Status | Since Version | Notes |
|---|---|---|---|
| MySQL | ✗ Not Supported | — | Not supported. Preventing overlapping ranges requires triggers or application logic. |
| PostgreSQL | ✓ Supported | 9.0 | EXCLUDE USING index_method (col WITH op, ...). Uses GiST or SP-GiST indexes. The btree_gist extension is usually needed to mix btree-comparable columns (like INT) with range/geometric operators. Can use any operator with an appropriate operator class. |
| SQL Server | ✗ Not Supported | — | Not supported. Only UNIQUE and CHECK constraints available; overlap prevention requires triggers. |
| Oracle | ✗ Not Supported | — | Not supported. Only UNIQUE and CHECK constraints available. |
| SQLite | ✗ Not Supported | — | Not supported. Only UNIQUE and CHECK constraints available. |
Unique to PostgreSQL. Enables database-enforced non-overlap rules (e.g., no two reservations for the same room in the same time window) declaratively, without triggers or application checks.
Not supported. Preventing overlapping ranges requires triggers or application logic.
EXCLUDE USING index_method (col WITH op, ...). Uses GiST or SP-GiST indexes. The btree_gist extension is usually needed to mix btree-comparable columns (like INT) with range/geometric operators. Can use any operator with an appropriate operator class.
Not supported. Only UNIQUE and CHECK constraints available; overlap prevention requires triggers.
Not supported. Only UNIQUE and CHECK constraints available.
Not supported. Only UNIQUE and CHECK constraints available.