我正在try 为我正在开发的应用程序创建受限的DB用户,我想删除我用于实验的Postgres数据库用户.是否有任何方法可以删除用户而不必先手动撤销其所有权限,或撤销用户拥有的所有授权?
我正在try 为我正在开发的应用程序创建受限的DB用户,我想删除我用于实验的Postgres数据库用户.是否有任何方法可以删除用户而不必先手动撤销其所有权限,或撤销用户拥有的所有授权?
怎么样
DROP USER <username>
这实际上是DROP ROLE
的别名.
您必须明确地删除与该用户关联的任何特权,还必须将其所有权移动到其他角色(或删除对象).
这最好通过以下方式实现:
REASSIGN OWNED BY <olduser> TO <newuser>
和
DROP OWNED BY <olduser>
后者将删除授予用户的任何特权.
See the postgres docs for DROP ROLE 和 the 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: