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.
Compatibility
| Database System | Support Status | Since Version | Notes |
|---|---|---|---|
| MySQL | Not Supported | - | Not supported. Preventing overlapping ranges requires triggers or application logic. |
| PostgreSQL | Native | 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. |
Details
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.
Standard Syntax
Version Support
Per-Database Syntax & Notes
MySQL Alternative syntax
Not supported. Preventing overlapping ranges requires triggers or application logic.
PostgreSQL Native syntax
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 Alternative syntax
Not supported. Only UNIQUE and CHECK constraints available; overlap prevention requires triggers.
Oracle Alternative syntax
Not supported. Only UNIQUE and CHECK constraints available.
SQLite Alternative syntax
Not supported. Only UNIQUE and CHECK constraints available.