简体   繁体   English

postgres 中排除约束的要点

[英]gist in exclude constraint in postgres

I created table using exclude constraint.but i do not know the use of gist in exclude constraint?Why we specify the gist keyword in exclude constraint?.Any specify reason for this.我使用排除约束创建表。但我不知道在排除约束中使用 gist?为什么我们在排除约束中指定 gist 关键字?任何指定原因。

CREATE TABLE Employee_age_Details(
name varchar(50),
age integer,
EXCLUDE USING gist
(age WITH <>));

The default index type, Btree, does not offer support for the '<>' operator.默认索引类型 Btree 不支持“<>”运算符。 The GiST index type (under btree_gist) does. GiST 索引类型(在 btree_gist 下)可以。 You must use an index type which supports the operator.您必须使用支持运算符的索引类型。

If you changed the constraint operator to '=', then you could omit the "gist".如果您将约束运算符更改为“=”,那么您可以省略“要点”。 But in that case you should just use a unique constraint, as it does the same thing better.但在这种情况下,您应该只使用唯一约束,因为它可以更好地完成相同的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM