Bossy Lobster

A blog by Danny Hermes; musing on tech, mathematics, etc.

Edit on GitHub

Almost unique (constraints)

almost-unique

It turns out it's quite straightforward to construct an "almost unique" constraint in PostgreSQL via EXCLUDE.

I was recently stuck in a jam in our PostgreSQL database during a feature migration. We needed a "partial UNIQUE" constraint and I was surprised to find out that PostgreSQL doesn't support them1 …