软件下载吧文章资讯

分类分类

PostgreSQL 实现快速删除一个用户

2024-02-14 10:19作者:下载吧

背景

在多租户场景或者其他场景下,很多时候需要主动清理一些用户,本文将介绍PostgreSQL 下如何快速删除一个用户(role)。

具体方法

一般情况下直接执行 drop role xxx; 就可以把这个用户删除。但是很多时候会因为用户有依赖而报错。

权限依赖

postgres=# create role test with login;
CREATE ROLE
postgres=# grant all on database postgres to test;
GRANT
postgres=# drop role test;
ERROR: role “test” cannot be dropped because some objects depend on it
DETAIL: privileges for database postgres

展开全部

相关文章

说两句网友评论
    我要跟贴
    取消