如何在 PostgreSQL 9 中禁用触发器?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7805558/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-20 23:22:36  来源:igfitidea点击:

How to disable triggers in PostgreSQL 9?

postgresqltriggers

提问by André

In PostgreSQl 8.x to disable triggers I do something like:

在 PostgreSQl 8.x 中禁用触发器,我执行以下操作:

ALTER TABLE table DISABLE TRIGGER ALL;

When I do this in PostgreSQL 9 I get the following:

当我在 PostgreSQL 9 中这样做时,我得到以下信息:

my_database=> ALTER TABLE my_table DISABLE TRIGGER ALL;
ERROR:  permission denied: "RI_ConstraintTrigger_25366" is a system trigger

PS: This table was created by the user that is running this command.

PS:此表是由运行此命令的用户创建的。

Any clues on this?

这有什么线索吗?

回答by TomH

Some triggers are added automatically to enforce constraints, and those can't be disabled unless you are a superuser. If you only want to disable the normal triggers which you have added then do this:

某些触发器会自动添加以强制执行约束,除非您是超级用户,否则无法禁用这些触发器。如果您只想禁用已添加的普通触发器,请执行以下操作:

ALTER TABLE table DISABLE TRIGGER USER;