我正在try 为我正在开发的应用程序创建受限的DB用户,我想删除我用于实验的Postgres数据库用户.是否有任何方法可以删除用户而不必先手动撤销其所有权限,或撤销用户拥有的所有授权?

推荐答案

怎么样

DROP USER <username>

这实际上是DROP ROLE的别名.

您必须明确地删除与该用户关联的任何特权,还必须将其所有权移动到其他角色(或删除对象).

这最好通过以下方式实现:

REASSIGN OWNED BY <olduser> TO <newuser>

DROP OWNED BY <olduser>

后者将删除授予用户的任何特权.

See the postgres docs for DROP ROLEthe more detailed description of this.


Addition:

Apparently, trying to drop a user by using the comm和s mentioned here will only work if you are executing them while being connected to the same database that the original GRANTS were made from, as discussed here:

https://www.postgresql.org/message-id/83894A1821034948BA27FE4DAA47427928F7C29922%40apde03.APD.Satcom.Local

Postgresql相关问答推荐

Psql:Windows 10上奇怪的错误输出编码

在特定值的组聚合中添加标签列作为结果

Postgres从spark触发post-write

如何返回old_ids和重复行的映射';来自PostgreSQL函数的s new_id

在 Windows 上使用 rsync 进行 Postgresql 副本升级

如何展平也在关系中使用的区分大小写的列

在查询中的复合外键/主键列上连接表

为什么 PostgreSQL 将用户和组合并为角色?

Mac psql/readline - 未加载库

gem install pg 无法绑定到 libpq

PostgreSQL:将时间戳转换为时间 - 或仅从时间戳列中检索时间

Postgresql:在插入列时(或之前)自动小写文本

如何禁用 postgresql缓存优化?

Postgres NOT IN (null) 没有结果

如何在 postgres 中使用 json_populate_recordset 解析 json

使用 RPostgreSQL 写入特定模式

如何在 redshift 中对字段进行 GROUP BY 和 CONCATENATE

Postgis / Geodjango:无法确定数据库的 PostGIS 版本

判断 PostgreSQL 中的角色是否设置了密码

如何使用 postgresql 按计数排序?