Being a new user of postgres, I have created a database in postgres 13. It contains tables including 4 Fields
I want to create a constraint that will check that for an identical entity number, the From and To fields of a record must not overlap with another record.
I have proposed the exclude constraint below but it does not work
ADD CONSTRAINT no_overlap EXCLUDE USING GIST ("HoleID" WITH =, ("mFrom", "mTo") WITH &&);
Thank you for helping me.
You can create the constraint like this:
ALTER TABLE tab
ADD CONSTRAINT no_overlap EXCLUDE USING gist (
"HoleID" WITH =,
numrange("mFrom", "mTo") WITH &&
);
You should never store a timestamp as number.