仅允许触发器更新列

时间:2013-11-21 12:08:27

标签: sql postgresql triggers privileges

我有两个表,t1(foo)t2(bar),以及更新t2.bar的触发器,可将t1.foo更新为其他内容。

首先,我想通过在t1上更新之前使用触发器来禁止t1.foo上的任何更新,该触发器始终抛出异常。但是,这不会阻止第一次触发的变化吗?

我该怎么做?

1 个答案:

答案 0 :(得分:1)

使用“守护程序”角色(此专用目的的非登录角色)拥有触发器功能并结合SECURITY DEFINER并向t1授予必要的权限。

这些相关问题的详细信息:
Is there a way to disable updates/deletes but still allow triggers to perform them?
Allow insertion only from within a trigger

相关问题