時間:2024-02-14 10:19作者:下載吧人氣:24
在多租戶場景或者其他場景下,很多時候需要主動清理一些用戶,本文將介紹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
網友評論