gpt4 book ai didi

postgresql - 撤销 PostgreSQL 中其他用户授予的权限

转载 作者:行者123 更新时间:2023-11-29 13:27:52 26 4
gpt4 key购买 nike

在 PostgreSQL 中,当 super 用户授予任何权限时(例如 GRANT SELECT ON TABLE table_name),只有 super 用户可以撤销它们。

有没有其他 super 用户可以撤销上述授权的方法?

编辑:这是我正在运行的示例查询:更改 SCHEMA my_schema 中的默认权限从 public CASCADE 中取消对表的选择;但是,即使在刷新所有内容之后,当我查看架构时,上述默认权限仍然显示。我已经用我的 super 用户帐户和 postgres 帐户运行它,都没有用。

最佳答案

来自documentation :

If a superuser chooses to issue a GRANT or REVOKE command, the command is performed as though it were issued by the owner of the affected object.

因此任何 super 用户都可以撤销特权,即使是其他 super 用户授予的特权。

您可以使用命令 ALTER DEFAULT PRIVILEGESinitial 权限(创建对象时分配的权限)设置为 PostgreSQL 默认权限以外的其他权限。但是,运行该命令只会影响(来自文档):

the privileges that will be applied to objects created in the future. (It does not affect privileges assigned to already-existing objects.)

更改现有对象的权限需要单独的 GRANTREVOKE,但您也可以应用如下快捷方式:

{GRANT | REVOKE} [privileges] ON ALL TABLES IN SCHEMA [schema name];

对于序列和函数也是如此。

关于postgresql - 撤销 PostgreSQL 中其他用户授予的权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30267135/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com