Skip to content

Instantly share code, notes, and snippets.

View TilavovD's full-sized avatar
🎯
Focusing

Dostonbek Tilavov TilavovD

🎯
Focusing
  • Inha University in Tashkent
  • Uzbekistan
View GitHub Profile
@fphilipe
fphilipe / exclude.sql
Last active April 25, 2024 23:17
PostgreSQL EXCLUDE constraint
CREATE EXTENSION btree_gist;
CREATE TABLE room_reservations (
room_id integer,
reserved_at timestamptz,
reserved_until timestamptz,
canceled boolean DEFAULT false,
EXCLUDE USING gist (
room_id WITH =, tstzrange(reserved_at, reserved_until) WITH &&
) WHERE (not canceled)