[英]Postgres drop exclusion constraint
I ran this DDL to add an exclusion constraint to a table:我运行此 DDL 以向表添加排除约束:
ALTER TABLE recurring_charges
ADD EXCLUDE USING GIST (period WITH &&);
Now I want to remove the constraint - how do I do that?现在我想删除约束 - 我该怎么做? I tried some variations of
ALTER TABLE ... DROP EXCLUDE
and DROP CONSTRAINT
but nothing seems to work.我尝试了
ALTER TABLE ... DROP EXCLUDE
和DROP CONSTRAINT
一些变体,但似乎没有任何效果。
Figured it out - looks like it generated a name for the constraint that I have to use.想通了 - 看起来它为我必须使用的约束生成了一个名称。
ALTER TABLE recurring_charges
DROP CONSTRAINT recurring_charges_period_excl;
And now I've updated my original DDL to use the full ADD CONSTRAINT
syntax so that I can name my constraint rather than relying on automatic naming behavior:现在我已经更新了我的原始 DDL 以使用完整的
ADD CONSTRAINT
语法,以便我可以命名我的约束而不是依赖于自动命名行为:
ALTER TABLE recurring_charges
ADD CONSTRAINT recurring_charges_period_excl EXCLUDE USING GIST (period WITH &&);
要添加到上述答案中,要找出约束名称,您可以使用以下命令在 psql 中找到它:
\\d+ tableName
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.