postgresql删除用户提示ERROR: role postgres1 cannot be dropped because some objects depend on it

余生长醉 提交于 2020-12-20 11:10:23

作者:瀚高PG实验室 (Highgo PG Lab)- 徐云鹤

删除用户可以使用如下命令:

drop user postgres1;

如果提示如下内容则说明该用户下有所属对象。

postgres=# drop user postgres1 ;
ERROR:  role "postgres1" cannot be dropped because some objects depend on it

需要通过如下两条命令进行删除。

drop owned by postgres1 cascade;
drop user postgres1;

将想删除的用户名替换postgres1即可。
删除前确保连接的数据库正确,执行删除命令前需三思而后行~~
截至PG13,没有 drop user postgres1 cascade;命令。以后应该也不会有。

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!