이 정의가있는 테이블이 있다고 가정 해 보겠습니다.PostgreSQL 데이터베이스에서 범위 중복 제한을 선언하는 방법?
range (
id bigint primary key,
colourId int references colour(id),
smellId int references smell(id),
from bigint,
to bigint
)
이 테이블은 사실 엄청나게 큰 테이블의 축소 된 뷰입니다.
item (
id bigint primary key,
colourId int references colour(id),
smellId int references smell(id),
CONSTRAINT item_colour_smell_unique UNIQUE (colour, smell, id)
)
range
테이블에서 item_colour_smell_unique
제약 조건을 변환하고 싶습니다. colourId
및 smellId
열 값을 가져 오는 동안 범위 [from, to]
의 겹침을 감시해야합니다.