Equivalent to exclusion constraint composed of integer and range

风格不统一 提交于 2019-11-28 06:04:00

问题


I need to have something equivalent to this exclusion constraint

drop table if exists t;
create table t (
    i int,
    tsr tstzrange,
    exclude using gist (i with =, tsr with &&)
);
ERROR:  data type integer has no default operator class for access method "gist"
HINT:  You must specify an operator class for the index or define a default operator class for the data type.

I guess the problem is obvious from the error message. How to do it?


回答1:


You need to install the additional module btree_gist to make it work. The module installs the missing operator class.

Details in this related answer:
Exclusion constraint on a bitstring column with bitwise AND operator

More at this answer on dba.SE:
PostgreSQL EXCLUDE USING error: Data type integer has no default operator class



来源:https://stackoverflow.com/questions/20908570/equivalent-to-exclusion-constraint-composed-of-integer-and-range

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!